why does my same zipcode plot rerun no longer run in python?
I just tested this code and it worked fine, only for me to change my plot to a bar chart and then after rerunning the file, it's showing me value error. I initially ran it multiple times because I was trying to set the x-axis to have the zipcodes in steps of 5 and now it does not run anymore. Now I have gone back to just plot to test but it still does not run. I do not understand what could have changed. The error says: ValueError: x and y must have same first dimension, but have shapes (55,) and (22,). What does this mean?
myzip = [60601, 60602, 60603, 60604, 60605, 60606, 60607, 60608, 60609, 60610, 60611, 60612, 60613, 60614, 60615, 60616, 60617, 60618, 60619, 60620, 60621, 60622, 60623, 60624, 60625, 60626, 60628, 60629, 60630, 60631, 60632, 60634, 60636, 60637, 60638, 60639, 60640, 60641, 60643, 60644, 60645, 60646, 60647, 60649, 60651, 60652, 60653, 60654, 60655, 60656, 60657, 60659, 60660, 60661, 60707]
frq = [6, 4, 5, 1, 2, 7, 1, 12, 10, 6, 6, 4, 6, 9, 4, 3, 11, 13, 6, 6, 4, 7, 5, 3, 5, 3, 8, 7, 8, 3, 6, 8, 1, 2, 4, 12, 8, 5, 7, 1, 1, 1, 11, 5, 2, 7, 3, 3, 3, 2, 11, 5, 3, 3, 2]
import numpy as np
import matplotlib.pyplot as plt
plt.close()
plt.plot(myzip,frq,'bo',Label='clinics in each zipcode', color='purple')
plt.xticks(rotation=45)
plt.xlabel('zipcodes')
plt.ylabel('Number of clinics')
plt.title('Clinics per zipcode in Chicago')
plt.legend()
plt.show()
python list numpy plot
add a comment |
I just tested this code and it worked fine, only for me to change my plot to a bar chart and then after rerunning the file, it's showing me value error. I initially ran it multiple times because I was trying to set the x-axis to have the zipcodes in steps of 5 and now it does not run anymore. Now I have gone back to just plot to test but it still does not run. I do not understand what could have changed. The error says: ValueError: x and y must have same first dimension, but have shapes (55,) and (22,). What does this mean?
myzip = [60601, 60602, 60603, 60604, 60605, 60606, 60607, 60608, 60609, 60610, 60611, 60612, 60613, 60614, 60615, 60616, 60617, 60618, 60619, 60620, 60621, 60622, 60623, 60624, 60625, 60626, 60628, 60629, 60630, 60631, 60632, 60634, 60636, 60637, 60638, 60639, 60640, 60641, 60643, 60644, 60645, 60646, 60647, 60649, 60651, 60652, 60653, 60654, 60655, 60656, 60657, 60659, 60660, 60661, 60707]
frq = [6, 4, 5, 1, 2, 7, 1, 12, 10, 6, 6, 4, 6, 9, 4, 3, 11, 13, 6, 6, 4, 7, 5, 3, 5, 3, 8, 7, 8, 3, 6, 8, 1, 2, 4, 12, 8, 5, 7, 1, 1, 1, 11, 5, 2, 7, 3, 3, 3, 2, 11, 5, 3, 3, 2]
import numpy as np
import matplotlib.pyplot as plt
plt.close()
plt.plot(myzip,frq,'bo',Label='clinics in each zipcode', color='purple')
plt.xticks(rotation=45)
plt.xlabel('zipcodes')
plt.ylabel('Number of clinics')
plt.title('Clinics per zipcode in Chicago')
plt.legend()
plt.show()
python list numpy plot
2
Maybe you just need to re-initialize (even reboot?) as I can see your plot just fine
– vav
Nov 14 '18 at 3:49
Thank you @vav I called the dataset from a database. I must have lost the connection, just reran it and it worked! Is there a way to let it show more zipcodes when plotting a bar chart? I tried np.arange(60601,60708,5) but I got the error: 'shape mismatch, objects cannot be broadcast to a single shape'
– cheena
Nov 14 '18 at 4:28
just keep an eye that len(myzip)==len(frq). your arange is 22 elements, how many elements in second set?
– vav
Nov 14 '18 at 4:37
its 22 as well cos the frequency was counted from the clinics zipcodes
– cheena
Nov 14 '18 at 4:42
add a comment |
I just tested this code and it worked fine, only for me to change my plot to a bar chart and then after rerunning the file, it's showing me value error. I initially ran it multiple times because I was trying to set the x-axis to have the zipcodes in steps of 5 and now it does not run anymore. Now I have gone back to just plot to test but it still does not run. I do not understand what could have changed. The error says: ValueError: x and y must have same first dimension, but have shapes (55,) and (22,). What does this mean?
myzip = [60601, 60602, 60603, 60604, 60605, 60606, 60607, 60608, 60609, 60610, 60611, 60612, 60613, 60614, 60615, 60616, 60617, 60618, 60619, 60620, 60621, 60622, 60623, 60624, 60625, 60626, 60628, 60629, 60630, 60631, 60632, 60634, 60636, 60637, 60638, 60639, 60640, 60641, 60643, 60644, 60645, 60646, 60647, 60649, 60651, 60652, 60653, 60654, 60655, 60656, 60657, 60659, 60660, 60661, 60707]
frq = [6, 4, 5, 1, 2, 7, 1, 12, 10, 6, 6, 4, 6, 9, 4, 3, 11, 13, 6, 6, 4, 7, 5, 3, 5, 3, 8, 7, 8, 3, 6, 8, 1, 2, 4, 12, 8, 5, 7, 1, 1, 1, 11, 5, 2, 7, 3, 3, 3, 2, 11, 5, 3, 3, 2]
import numpy as np
import matplotlib.pyplot as plt
plt.close()
plt.plot(myzip,frq,'bo',Label='clinics in each zipcode', color='purple')
plt.xticks(rotation=45)
plt.xlabel('zipcodes')
plt.ylabel('Number of clinics')
plt.title('Clinics per zipcode in Chicago')
plt.legend()
plt.show()
python list numpy plot
I just tested this code and it worked fine, only for me to change my plot to a bar chart and then after rerunning the file, it's showing me value error. I initially ran it multiple times because I was trying to set the x-axis to have the zipcodes in steps of 5 and now it does not run anymore. Now I have gone back to just plot to test but it still does not run. I do not understand what could have changed. The error says: ValueError: x and y must have same first dimension, but have shapes (55,) and (22,). What does this mean?
myzip = [60601, 60602, 60603, 60604, 60605, 60606, 60607, 60608, 60609, 60610, 60611, 60612, 60613, 60614, 60615, 60616, 60617, 60618, 60619, 60620, 60621, 60622, 60623, 60624, 60625, 60626, 60628, 60629, 60630, 60631, 60632, 60634, 60636, 60637, 60638, 60639, 60640, 60641, 60643, 60644, 60645, 60646, 60647, 60649, 60651, 60652, 60653, 60654, 60655, 60656, 60657, 60659, 60660, 60661, 60707]
frq = [6, 4, 5, 1, 2, 7, 1, 12, 10, 6, 6, 4, 6, 9, 4, 3, 11, 13, 6, 6, 4, 7, 5, 3, 5, 3, 8, 7, 8, 3, 6, 8, 1, 2, 4, 12, 8, 5, 7, 1, 1, 1, 11, 5, 2, 7, 3, 3, 3, 2, 11, 5, 3, 3, 2]
import numpy as np
import matplotlib.pyplot as plt
plt.close()
plt.plot(myzip,frq,'bo',Label='clinics in each zipcode', color='purple')
plt.xticks(rotation=45)
plt.xlabel('zipcodes')
plt.ylabel('Number of clinics')
plt.title('Clinics per zipcode in Chicago')
plt.legend()
plt.show()
python list numpy plot
python list numpy plot
asked Nov 14 '18 at 3:40
cheenacheena
2410
2410
2
Maybe you just need to re-initialize (even reboot?) as I can see your plot just fine
– vav
Nov 14 '18 at 3:49
Thank you @vav I called the dataset from a database. I must have lost the connection, just reran it and it worked! Is there a way to let it show more zipcodes when plotting a bar chart? I tried np.arange(60601,60708,5) but I got the error: 'shape mismatch, objects cannot be broadcast to a single shape'
– cheena
Nov 14 '18 at 4:28
just keep an eye that len(myzip)==len(frq). your arange is 22 elements, how many elements in second set?
– vav
Nov 14 '18 at 4:37
its 22 as well cos the frequency was counted from the clinics zipcodes
– cheena
Nov 14 '18 at 4:42
add a comment |
2
Maybe you just need to re-initialize (even reboot?) as I can see your plot just fine
– vav
Nov 14 '18 at 3:49
Thank you @vav I called the dataset from a database. I must have lost the connection, just reran it and it worked! Is there a way to let it show more zipcodes when plotting a bar chart? I tried np.arange(60601,60708,5) but I got the error: 'shape mismatch, objects cannot be broadcast to a single shape'
– cheena
Nov 14 '18 at 4:28
just keep an eye that len(myzip)==len(frq). your arange is 22 elements, how many elements in second set?
– vav
Nov 14 '18 at 4:37
its 22 as well cos the frequency was counted from the clinics zipcodes
– cheena
Nov 14 '18 at 4:42
2
2
Maybe you just need to re-initialize (even reboot?) as I can see your plot just fine
– vav
Nov 14 '18 at 3:49
Maybe you just need to re-initialize (even reboot?) as I can see your plot just fine
– vav
Nov 14 '18 at 3:49
Thank you @vav I called the dataset from a database. I must have lost the connection, just reran it and it worked! Is there a way to let it show more zipcodes when plotting a bar chart? I tried np.arange(60601,60708,5) but I got the error: 'shape mismatch, objects cannot be broadcast to a single shape'
– cheena
Nov 14 '18 at 4:28
Thank you @vav I called the dataset from a database. I must have lost the connection, just reran it and it worked! Is there a way to let it show more zipcodes when plotting a bar chart? I tried np.arange(60601,60708,5) but I got the error: 'shape mismatch, objects cannot be broadcast to a single shape'
– cheena
Nov 14 '18 at 4:28
just keep an eye that len(myzip)==len(frq). your arange is 22 elements, how many elements in second set?
– vav
Nov 14 '18 at 4:37
just keep an eye that len(myzip)==len(frq). your arange is 22 elements, how many elements in second set?
– vav
Nov 14 '18 at 4:37
its 22 as well cos the frequency was counted from the clinics zipcodes
– cheena
Nov 14 '18 at 4:42
its 22 as well cos the frequency was counted from the clinics zipcodes
– cheena
Nov 14 '18 at 4:42
add a comment |
0
active
oldest
votes
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
);
);
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%2f53292873%2fwhy-does-my-same-zipcode-plot-rerun-no-longer-run-in-python%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
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%2f53292873%2fwhy-does-my-same-zipcode-plot-rerun-no-longer-run-in-python%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
2
Maybe you just need to re-initialize (even reboot?) as I can see your plot just fine
– vav
Nov 14 '18 at 3:49
Thank you @vav I called the dataset from a database. I must have lost the connection, just reran it and it worked! Is there a way to let it show more zipcodes when plotting a bar chart? I tried np.arange(60601,60708,5) but I got the error: 'shape mismatch, objects cannot be broadcast to a single shape'
– cheena
Nov 14 '18 at 4:28
just keep an eye that len(myzip)==len(frq). your arange is 22 elements, how many elements in second set?
– vav
Nov 14 '18 at 4:37
its 22 as well cos the frequency was counted from the clinics zipcodes
– cheena
Nov 14 '18 at 4:42