Matplotlib code not executing due to labels?












1















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










share|improve this question

























  • 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 '18 at 19:14











  • Sorry what I meant is that my notebook is not giving me the output.

    – defiler
    Nov 19 '18 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 '18 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 '18 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 '18 at 19:22


















1















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










share|improve this question

























  • 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 '18 at 19:14











  • Sorry what I meant is that my notebook is not giving me the output.

    – defiler
    Nov 19 '18 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 '18 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 '18 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 '18 at 19:22
















1












1








1








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










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 19 '18 at 19:23







defiler

















asked Nov 19 '18 at 19:11









defilerdefiler

104




104













  • 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 '18 at 19:14











  • Sorry what I meant is that my notebook is not giving me the output.

    – defiler
    Nov 19 '18 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 '18 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 '18 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 '18 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 '18 at 19:14











  • Sorry what I meant is that my notebook is not giving me the output.

    – defiler
    Nov 19 '18 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 '18 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 '18 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 '18 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 '18 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 '18 at 19:14













Sorry what I meant is that my notebook is not giving me the output.

– defiler
Nov 19 '18 at 19:17







Sorry what I meant is that my notebook is not giving me the output.

– defiler
Nov 19 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 at 19:22














1 Answer
1






active

oldest

votes


















1














enter image description here



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,'.')






share|improve this answer
























  • Thank you! solved :)

    – defiler
    Nov 19 '18 at 19:28











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















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

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














enter image description here



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,'.')






share|improve this answer
























  • Thank you! solved :)

    – defiler
    Nov 19 '18 at 19:28
















1














enter image description here



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,'.')






share|improve this answer
























  • Thank you! solved :)

    – defiler
    Nov 19 '18 at 19:28














1












1








1







enter image description here



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,'.')






share|improve this answer













enter image description here



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,'.')







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 19 '18 at 19:25









Althaf1467Althaf1467

937




937













  • Thank you! solved :)

    – defiler
    Nov 19 '18 at 19:28



















  • Thank you! solved :)

    – defiler
    Nov 19 '18 at 19:28

















Thank you! solved :)

– defiler
Nov 19 '18 at 19:28





Thank you! solved :)

– defiler
Nov 19 '18 at 19:28




















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Guess what letter conforming each word

Port of Spain

Run scheduled task as local user group (not BUILTIN)