set marker to scale with y axis (with limits)












0















I want to scale my marker points with my y-axis values in matplotlib. I thought i could use "counts" from pandas to count the instances of each y-axis value, then set that range to the size values of my scatterplot, but the scale is all messed up and the marker points become huge (the range of y-axis values range from 1 to 17,000). What is a good way to scale this number back to something between 1 and 10?



import pandas as pd
import matplotlib.pyplot as plt

data = pd.read_excel("dataset.xlsx")

scale_range = pd.value_counts(data["y_axis"].values, sort = True))

plt.scatter(data["x_axis"], data["y_axis"], s = scale_range)
plt.axis([0, 120, 0, 1])

plt.show('dataset_out.png')


Any help is appreciated, thanks.










share|improve this question




















  • 2





    Divide by 1700?

    – busybear
    Nov 20 '18 at 19:52











  • lol yeah i gues i could find some percent to make the values in line to the scale i want. I was looking for a more "pythonic" way of doing it, Thanks though!

    – Dane Kania
    Nov 20 '18 at 19:54











  • I think that's a pretty "pythonic" method. It's straightforward at least. Another thing you might want to consider is size sets the area and not the diameter.

    – busybear
    Nov 20 '18 at 20:03













  • I wonder why that approach works at all. value_counts will produce a series of unique elements of its argument, which are generally less than the number of total elements. So either each value occurs exactly once, then you get all 1 in scale_range, or scale_range does not even have as many elements as x_axis, which might throw an error, or at least will give an incorrect plot. In that sense, why not use the y_axis values themselves? plt.scatter(data["x_axis"], data["y_axis"], s = data["y_axis"]+10)?

    – ImportanceOfBeingErnest
    Nov 20 '18 at 20:06













  • I tried your method and it doesnt scale at all. Im not really sure why, your method seems like a fine idea.

    – Dane Kania
    Nov 20 '18 at 20:25
















0















I want to scale my marker points with my y-axis values in matplotlib. I thought i could use "counts" from pandas to count the instances of each y-axis value, then set that range to the size values of my scatterplot, but the scale is all messed up and the marker points become huge (the range of y-axis values range from 1 to 17,000). What is a good way to scale this number back to something between 1 and 10?



import pandas as pd
import matplotlib.pyplot as plt

data = pd.read_excel("dataset.xlsx")

scale_range = pd.value_counts(data["y_axis"].values, sort = True))

plt.scatter(data["x_axis"], data["y_axis"], s = scale_range)
plt.axis([0, 120, 0, 1])

plt.show('dataset_out.png')


Any help is appreciated, thanks.










share|improve this question




















  • 2





    Divide by 1700?

    – busybear
    Nov 20 '18 at 19:52











  • lol yeah i gues i could find some percent to make the values in line to the scale i want. I was looking for a more "pythonic" way of doing it, Thanks though!

    – Dane Kania
    Nov 20 '18 at 19:54











  • I think that's a pretty "pythonic" method. It's straightforward at least. Another thing you might want to consider is size sets the area and not the diameter.

    – busybear
    Nov 20 '18 at 20:03













  • I wonder why that approach works at all. value_counts will produce a series of unique elements of its argument, which are generally less than the number of total elements. So either each value occurs exactly once, then you get all 1 in scale_range, or scale_range does not even have as many elements as x_axis, which might throw an error, or at least will give an incorrect plot. In that sense, why not use the y_axis values themselves? plt.scatter(data["x_axis"], data["y_axis"], s = data["y_axis"]+10)?

    – ImportanceOfBeingErnest
    Nov 20 '18 at 20:06













  • I tried your method and it doesnt scale at all. Im not really sure why, your method seems like a fine idea.

    – Dane Kania
    Nov 20 '18 at 20:25














0












0








0








I want to scale my marker points with my y-axis values in matplotlib. I thought i could use "counts" from pandas to count the instances of each y-axis value, then set that range to the size values of my scatterplot, but the scale is all messed up and the marker points become huge (the range of y-axis values range from 1 to 17,000). What is a good way to scale this number back to something between 1 and 10?



import pandas as pd
import matplotlib.pyplot as plt

data = pd.read_excel("dataset.xlsx")

scale_range = pd.value_counts(data["y_axis"].values, sort = True))

plt.scatter(data["x_axis"], data["y_axis"], s = scale_range)
plt.axis([0, 120, 0, 1])

plt.show('dataset_out.png')


Any help is appreciated, thanks.










share|improve this question
















I want to scale my marker points with my y-axis values in matplotlib. I thought i could use "counts" from pandas to count the instances of each y-axis value, then set that range to the size values of my scatterplot, but the scale is all messed up and the marker points become huge (the range of y-axis values range from 1 to 17,000). What is a good way to scale this number back to something between 1 and 10?



import pandas as pd
import matplotlib.pyplot as plt

data = pd.read_excel("dataset.xlsx")

scale_range = pd.value_counts(data["y_axis"].values, sort = True))

plt.scatter(data["x_axis"], data["y_axis"], s = scale_range)
plt.axis([0, 120, 0, 1])

plt.show('dataset_out.png')


Any help is appreciated, thanks.







python matplotlib






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 20 '18 at 19:52







Dane Kania

















asked Nov 20 '18 at 19:49









Dane KaniaDane Kania

256




256








  • 2





    Divide by 1700?

    – busybear
    Nov 20 '18 at 19:52











  • lol yeah i gues i could find some percent to make the values in line to the scale i want. I was looking for a more "pythonic" way of doing it, Thanks though!

    – Dane Kania
    Nov 20 '18 at 19:54











  • I think that's a pretty "pythonic" method. It's straightforward at least. Another thing you might want to consider is size sets the area and not the diameter.

    – busybear
    Nov 20 '18 at 20:03













  • I wonder why that approach works at all. value_counts will produce a series of unique elements of its argument, which are generally less than the number of total elements. So either each value occurs exactly once, then you get all 1 in scale_range, or scale_range does not even have as many elements as x_axis, which might throw an error, or at least will give an incorrect plot. In that sense, why not use the y_axis values themselves? plt.scatter(data["x_axis"], data["y_axis"], s = data["y_axis"]+10)?

    – ImportanceOfBeingErnest
    Nov 20 '18 at 20:06













  • I tried your method and it doesnt scale at all. Im not really sure why, your method seems like a fine idea.

    – Dane Kania
    Nov 20 '18 at 20:25














  • 2





    Divide by 1700?

    – busybear
    Nov 20 '18 at 19:52











  • lol yeah i gues i could find some percent to make the values in line to the scale i want. I was looking for a more "pythonic" way of doing it, Thanks though!

    – Dane Kania
    Nov 20 '18 at 19:54











  • I think that's a pretty "pythonic" method. It's straightforward at least. Another thing you might want to consider is size sets the area and not the diameter.

    – busybear
    Nov 20 '18 at 20:03













  • I wonder why that approach works at all. value_counts will produce a series of unique elements of its argument, which are generally less than the number of total elements. So either each value occurs exactly once, then you get all 1 in scale_range, or scale_range does not even have as many elements as x_axis, which might throw an error, or at least will give an incorrect plot. In that sense, why not use the y_axis values themselves? plt.scatter(data["x_axis"], data["y_axis"], s = data["y_axis"]+10)?

    – ImportanceOfBeingErnest
    Nov 20 '18 at 20:06













  • I tried your method and it doesnt scale at all. Im not really sure why, your method seems like a fine idea.

    – Dane Kania
    Nov 20 '18 at 20:25








2




2





Divide by 1700?

– busybear
Nov 20 '18 at 19:52





Divide by 1700?

– busybear
Nov 20 '18 at 19:52













lol yeah i gues i could find some percent to make the values in line to the scale i want. I was looking for a more "pythonic" way of doing it, Thanks though!

– Dane Kania
Nov 20 '18 at 19:54





lol yeah i gues i could find some percent to make the values in line to the scale i want. I was looking for a more "pythonic" way of doing it, Thanks though!

– Dane Kania
Nov 20 '18 at 19:54













I think that's a pretty "pythonic" method. It's straightforward at least. Another thing you might want to consider is size sets the area and not the diameter.

– busybear
Nov 20 '18 at 20:03







I think that's a pretty "pythonic" method. It's straightforward at least. Another thing you might want to consider is size sets the area and not the diameter.

– busybear
Nov 20 '18 at 20:03















I wonder why that approach works at all. value_counts will produce a series of unique elements of its argument, which are generally less than the number of total elements. So either each value occurs exactly once, then you get all 1 in scale_range, or scale_range does not even have as many elements as x_axis, which might throw an error, or at least will give an incorrect plot. In that sense, why not use the y_axis values themselves? plt.scatter(data["x_axis"], data["y_axis"], s = data["y_axis"]+10)?

– ImportanceOfBeingErnest
Nov 20 '18 at 20:06







I wonder why that approach works at all. value_counts will produce a series of unique elements of its argument, which are generally less than the number of total elements. So either each value occurs exactly once, then you get all 1 in scale_range, or scale_range does not even have as many elements as x_axis, which might throw an error, or at least will give an incorrect plot. In that sense, why not use the y_axis values themselves? plt.scatter(data["x_axis"], data["y_axis"], s = data["y_axis"]+10)?

– ImportanceOfBeingErnest
Nov 20 '18 at 20:06















I tried your method and it doesnt scale at all. Im not really sure why, your method seems like a fine idea.

– Dane Kania
Nov 20 '18 at 20:25





I tried your method and it doesnt scale at all. Im not really sure why, your method seems like a fine idea.

– Dane Kania
Nov 20 '18 at 20:25












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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53400518%2fset-marker-to-scale-with-y-axis-with-limits%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
















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%2f53400518%2fset-marker-to-scale-with-y-axis-with-limits%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)