Matplotlib code not executing due to labels?
up vote
0
down vote
favorite
I'm using the salem_executions_data.csv, this is how it looks like:
year,month,accusations,executions
1962,1,0,0
1962,2,3,0
1962,3,4,0
1962,4,22,0
1962,5,39,0
1962,6,3,1
1962,7,12,5
1962,8,23,5
1962,9,33,9
1962,10,1,0
1962,11,3,0
1962,12,0,0
1963,1,0,0
1963,2,0,0
1963,3,0,0
Working with Python 2.7, what I wanted was to:
- Load the csv file
- Make a accusations vs executions using 3d scatter
And what I have so far is this:
import matplotlib.pyplot as plt
import csv
x =
y =
with open('data/salem_executions_data.csv','r') as csvfile:
plots = csv.reader(csvfile, delimiter=',')
from itertools import islice
for row in islice(plots,1,None):
for row in plots:
temp=row[int(str(2))]
x.append(temp)
temp=row[int(str(3))]
y.append(temp)
plt.plot(x,y)
plt.xlabel('Accusations')
plt.ylabel('Executions')
plt.title('Accusations vs Executions')
plt.legend()
plt.show()
Once I execute this cells I get no output code... Any help?
After adding %matplotlib inline this is the output I get, do you think its okay?
enter image description here
Update v3:
After changing plt.plot to plt.scatter:
enter image description here
python python-2.7 matplotlib
|
show 4 more comments
up vote
0
down vote
favorite
I'm using the salem_executions_data.csv, this is how it looks like:
year,month,accusations,executions
1962,1,0,0
1962,2,3,0
1962,3,4,0
1962,4,22,0
1962,5,39,0
1962,6,3,1
1962,7,12,5
1962,8,23,5
1962,9,33,9
1962,10,1,0
1962,11,3,0
1962,12,0,0
1963,1,0,0
1963,2,0,0
1963,3,0,0
Working with Python 2.7, what I wanted was to:
- Load the csv file
- Make a accusations vs executions using 3d scatter
And what I have so far is this:
import matplotlib.pyplot as plt
import csv
x =
y =
with open('data/salem_executions_data.csv','r') as csvfile:
plots = csv.reader(csvfile, delimiter=',')
from itertools import islice
for row in islice(plots,1,None):
for row in plots:
temp=row[int(str(2))]
x.append(temp)
temp=row[int(str(3))]
y.append(temp)
plt.plot(x,y)
plt.xlabel('Accusations')
plt.ylabel('Executions')
plt.title('Accusations vs Executions')
plt.legend()
plt.show()
Once I execute this cells I get no output code... Any help?
After adding %matplotlib inline this is the output I get, do you think its okay?
enter image description here
Update v3:
After changing plt.plot to plt.scatter:
enter image description here
python python-2.7 matplotlib
If you don't get any error, the code runs fine. What's the problem then? Where/How do you run the code?
– ImportanceOfBeingErnest
Nov 19 at 19:14
Sorry what I meant is that my notebook is not giving me the output.
– defiler
Nov 19 at 19:17
2
You probably didn't tell the notebook how to output anything. Usually people use either%matplotlib inline
or%matplotlib notebook
. You may also use%matplotlib tk
or%matplotlib qt
.
– ImportanceOfBeingErnest
Nov 19 at 19:19
It says /usr/local/lib/python2.7/dist-packages/matplotlib/axes/_axes.py:545: UserWarning: No labelled objects found. Use label='...' kwarg on individual plots. warnings.warn("No labelled objects found. "
– defiler
Nov 19 at 19:20
If you want a scatter plot instead of a line plot, you probably want to callplt.scatter(x,y)
instead ofplt.plot(x,y)
. You may want to sort your x,y points.
– John Anderson
Nov 19 at 19:22
|
show 4 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm using the salem_executions_data.csv, this is how it looks like:
year,month,accusations,executions
1962,1,0,0
1962,2,3,0
1962,3,4,0
1962,4,22,0
1962,5,39,0
1962,6,3,1
1962,7,12,5
1962,8,23,5
1962,9,33,9
1962,10,1,0
1962,11,3,0
1962,12,0,0
1963,1,0,0
1963,2,0,0
1963,3,0,0
Working with Python 2.7, what I wanted was to:
- Load the csv file
- Make a accusations vs executions using 3d scatter
And what I have so far is this:
import matplotlib.pyplot as plt
import csv
x =
y =
with open('data/salem_executions_data.csv','r') as csvfile:
plots = csv.reader(csvfile, delimiter=',')
from itertools import islice
for row in islice(plots,1,None):
for row in plots:
temp=row[int(str(2))]
x.append(temp)
temp=row[int(str(3))]
y.append(temp)
plt.plot(x,y)
plt.xlabel('Accusations')
plt.ylabel('Executions')
plt.title('Accusations vs Executions')
plt.legend()
plt.show()
Once I execute this cells I get no output code... Any help?
After adding %matplotlib inline this is the output I get, do you think its okay?
enter image description here
Update v3:
After changing plt.plot to plt.scatter:
enter image description here
python python-2.7 matplotlib
I'm using the salem_executions_data.csv, this is how it looks like:
year,month,accusations,executions
1962,1,0,0
1962,2,3,0
1962,3,4,0
1962,4,22,0
1962,5,39,0
1962,6,3,1
1962,7,12,5
1962,8,23,5
1962,9,33,9
1962,10,1,0
1962,11,3,0
1962,12,0,0
1963,1,0,0
1963,2,0,0
1963,3,0,0
Working with Python 2.7, what I wanted was to:
- Load the csv file
- Make a accusations vs executions using 3d scatter
And what I have so far is this:
import matplotlib.pyplot as plt
import csv
x =
y =
with open('data/salem_executions_data.csv','r') as csvfile:
plots = csv.reader(csvfile, delimiter=',')
from itertools import islice
for row in islice(plots,1,None):
for row in plots:
temp=row[int(str(2))]
x.append(temp)
temp=row[int(str(3))]
y.append(temp)
plt.plot(x,y)
plt.xlabel('Accusations')
plt.ylabel('Executions')
plt.title('Accusations vs Executions')
plt.legend()
plt.show()
Once I execute this cells I get no output code... Any help?
After adding %matplotlib inline this is the output I get, do you think its okay?
enter image description here
Update v3:
After changing plt.plot to plt.scatter:
enter image description here
python python-2.7 matplotlib
python python-2.7 matplotlib
edited Nov 19 at 19:23
asked Nov 19 at 19:11
defiler
12
12
If you don't get any error, the code runs fine. What's the problem then? Where/How do you run the code?
– ImportanceOfBeingErnest
Nov 19 at 19:14
Sorry what I meant is that my notebook is not giving me the output.
– defiler
Nov 19 at 19:17
2
You probably didn't tell the notebook how to output anything. Usually people use either%matplotlib inline
or%matplotlib notebook
. You may also use%matplotlib tk
or%matplotlib qt
.
– ImportanceOfBeingErnest
Nov 19 at 19:19
It says /usr/local/lib/python2.7/dist-packages/matplotlib/axes/_axes.py:545: UserWarning: No labelled objects found. Use label='...' kwarg on individual plots. warnings.warn("No labelled objects found. "
– defiler
Nov 19 at 19:20
If you want a scatter plot instead of a line plot, you probably want to callplt.scatter(x,y)
instead ofplt.plot(x,y)
. You may want to sort your x,y points.
– John Anderson
Nov 19 at 19:22
|
show 4 more comments
If you don't get any error, the code runs fine. What's the problem then? Where/How do you run the code?
– ImportanceOfBeingErnest
Nov 19 at 19:14
Sorry what I meant is that my notebook is not giving me the output.
– defiler
Nov 19 at 19:17
2
You probably didn't tell the notebook how to output anything. Usually people use either%matplotlib inline
or%matplotlib notebook
. You may also use%matplotlib tk
or%matplotlib qt
.
– ImportanceOfBeingErnest
Nov 19 at 19:19
It says /usr/local/lib/python2.7/dist-packages/matplotlib/axes/_axes.py:545: UserWarning: No labelled objects found. Use label='...' kwarg on individual plots. warnings.warn("No labelled objects found. "
– defiler
Nov 19 at 19:20
If you want a scatter plot instead of a line plot, you probably want to callplt.scatter(x,y)
instead ofplt.plot(x,y)
. You may want to sort your x,y points.
– John Anderson
Nov 19 at 19:22
If you don't get any error, the code runs fine. What's the problem then? Where/How do you run the code?
– ImportanceOfBeingErnest
Nov 19 at 19:14
If you don't get any error, the code runs fine. What's the problem then? Where/How do you run the code?
– ImportanceOfBeingErnest
Nov 19 at 19:14
Sorry what I meant is that my notebook is not giving me the output.
– defiler
Nov 19 at 19:17
Sorry what I meant is that my notebook is not giving me the output.
– defiler
Nov 19 at 19:17
2
2
You probably didn't tell the notebook how to output anything. Usually people use either
%matplotlib inline
or %matplotlib notebook
. You may also use %matplotlib tk
or %matplotlib qt
.– ImportanceOfBeingErnest
Nov 19 at 19:19
You probably didn't tell the notebook how to output anything. Usually people use either
%matplotlib inline
or %matplotlib notebook
. You may also use %matplotlib tk
or %matplotlib qt
.– ImportanceOfBeingErnest
Nov 19 at 19:19
It says /usr/local/lib/python2.7/dist-packages/matplotlib/axes/_axes.py:545: UserWarning: No labelled objects found. Use label='...' kwarg on individual plots. warnings.warn("No labelled objects found. "
– defiler
Nov 19 at 19:20
It says /usr/local/lib/python2.7/dist-packages/matplotlib/axes/_axes.py:545: UserWarning: No labelled objects found. Use label='...' kwarg on individual plots. warnings.warn("No labelled objects found. "
– defiler
Nov 19 at 19:20
If you want a scatter plot instead of a line plot, you probably want to call
plt.scatter(x,y)
instead of plt.plot(x,y)
. You may want to sort your x,y points.– John Anderson
Nov 19 at 19:22
If you want a scatter plot instead of a line plot, you probably want to call
plt.scatter(x,y)
instead of plt.plot(x,y)
. You may want to sort your x,y points.– John Anderson
Nov 19 at 19:22
|
show 4 more comments
1 Answer
1
active
oldest
votes
up vote
0
down vote
I get a scatter. I have not changed anything from your code. The only change i have made is to make it a scatter plot by replacing your code plt.plot(x,y)
with plt.plot(x,y,'.')
Thank you! solved :)
– defiler
Nov 19 at 19:28
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
I get a scatter. I have not changed anything from your code. The only change i have made is to make it a scatter plot by replacing your code plt.plot(x,y)
with plt.plot(x,y,'.')
Thank you! solved :)
– defiler
Nov 19 at 19:28
add a comment |
up vote
0
down vote
I get a scatter. I have not changed anything from your code. The only change i have made is to make it a scatter plot by replacing your code plt.plot(x,y)
with plt.plot(x,y,'.')
Thank you! solved :)
– defiler
Nov 19 at 19:28
add a comment |
up vote
0
down vote
up vote
0
down vote
I get a scatter. I have not changed anything from your code. The only change i have made is to make it a scatter plot by replacing your code plt.plot(x,y)
with plt.plot(x,y,'.')
I get a scatter. I have not changed anything from your code. The only change i have made is to make it a scatter plot by replacing your code plt.plot(x,y)
with plt.plot(x,y,'.')
answered Nov 19 at 19:25
Althaf1467
437
437
Thank you! solved :)
– defiler
Nov 19 at 19:28
add a comment |
Thank you! solved :)
– defiler
Nov 19 at 19:28
Thank you! solved :)
– defiler
Nov 19 at 19:28
Thank you! solved :)
– defiler
Nov 19 at 19:28
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53381137%2fmatplotlib-code-not-executing-due-to-labels%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
If you don't get any error, the code runs fine. What's the problem then? Where/How do you run the code?
– ImportanceOfBeingErnest
Nov 19 at 19:14
Sorry what I meant is that my notebook is not giving me the output.
– defiler
Nov 19 at 19:17
2
You probably didn't tell the notebook how to output anything. Usually people use either
%matplotlib inline
or%matplotlib notebook
. You may also use%matplotlib tk
or%matplotlib qt
.– ImportanceOfBeingErnest
Nov 19 at 19:19
It says /usr/local/lib/python2.7/dist-packages/matplotlib/axes/_axes.py:545: UserWarning: No labelled objects found. Use label='...' kwarg on individual plots. warnings.warn("No labelled objects found. "
– defiler
Nov 19 at 19:20
If you want a scatter plot instead of a line plot, you probably want to call
plt.scatter(x,y)
instead ofplt.plot(x,y)
. You may want to sort your x,y points.– John Anderson
Nov 19 at 19:22