I am trying to make a bar graph or a stacked bar graph with the count of each city.
The x-axis should be the the label of cluster and y-axis should be the count.
Something like these
Where the colors are different cities.
I have tried to use the hist funtions from pandas but cannot separate the cities.
I tend to lean towards plotly, in Jupyter, because it's interactive.
https://plotly.com/python/histograms/
https://www.fredlich.com/works/how-to-make-a-countplot-in-seaborn-plotly-and-matplotlib
https://towardsdatascience.com/histograms-with-plotly-express-complete-guide-d483656c5ad7
Also, Seaborn has some nice features too!
https://seaborn.pydata.org/generated/seaborn.countplot.html
Related
I'm exploring a dataset of world suicides from 1985 to 2016 and try to show the number of suicides by generation - they are divided into six categories in this dataset.
My goal is to create a scatter plot that includes the six generations in one figure. To do that, I created the normalised weights and plotted the data:
This is the code: https://i.stack.imgur.com/96XZz.png
This is the output: https://i.stack.imgur.com/QTwrN.png
It always appears in six different scatter plots. I have no idea why I couldn't put them in one figure, I have googled the way of using the ax parameter but didn't find any helpful guide or solution...
When plotting a line with many points, matplotlib automatically hides some x-axis ticks/labels to make sure all labels can fit.
If I want to plot a bar chat with many points, is there anyway to make matplotlib think of the x-axis in the same as with a line plot? Right now it's trying to squeeze in all the labels.
I would suggest specifiying the list of xtick labels :
plt.xticks([80,150,300]) ### In this case these are numbers, change them to your values
I have a basic bar chart with the x-axis having categorical values of countries. I want to give each bar, an image background of the country's flag, to make the chart more appealing also to eliminate the x-axis labels. I am currently using bokeh for my charts and I dont think it is possible via this. Any ideas for the same, maybe some other python libraries which might do the trick?
Thanks
I'm using Bokeh's hbar_stack() method in order to make a stacked horizontal bar chart.
In Matthew Rocklin's post here, the very first chart plots how long tasks take on different worker cores. It plots "read-block" and "pandas_read_text."
I was wondering how you could get multiple bars of a phase (ex. "read-block") onto the same y-axis when using hbar_stack(). Any general advice behind how this chart is created would also be helpful.
Is there any (simple or complex) way to recreate this plot in matplotlib?
I've tried plotting it using a scatter plot with two different x-values, while adding a small random number to it, but obviously it didn't produce the nice "ordered" effect seen above.
There's a package built on top of matplotlib called beeswarm that positions the points as requested.