I have a geopandas / matplotlib choropleth plot of a specific type of crime in Cheltenham (criminal damage and arson). I generated the plot (and associated legend) with the following code in a Jupyter notebook:
lsoaBounds.plot(column='Criminal damage and arson', cmap='Reds')
plt.legend(lsoaBounds['Criminal damage and arson'])
I have three questions:
How do I get the legend to show boxes, or swatches, rather than lines, to represent the values across the map?;
How do I sort the legend from highest value to lowest? and;
How do I split the legend across multiple columns?
Screenshot of output included below:
Related
I am aiming to combine two types of charts - a horizontal bar chart using a categorical axis and some form of line, scatter, violin, or similar chart that displays a trace paired with each category on the same axes but "dithers" up and down around some bounds.
Below is sort of what I'm trying to create. However, the shape of the violin chart is generated automatically behind the scenes from scattered points. In my use case, I already have what the distributions are and I'm trying to plot them over top of related data.
I can't find a utility in Plotly that allows me to specify a categorical axis, but then offset points, lines, etc from that category-derived position on the axis.
I am working with my genes expression dataset and created this heatmap:
On the X axis of this heatmap, I have my different cell types.
I want to have only one xtick in the center of each cell type and remove all of the other excess xticks.
Additionally, I want the last line of this heatmap to have different distinct colors for each cell type.
I searched for days for some possible solutions and tried to manipulate some of pandas and seaborn functions, but couldn't solve this problem.
It is supposed to look more like this:
I'm trying to display a barplot that shows values and percentage on the left and right respectfully. I tried myself but I couldn't quite get it. I want to make sure the value and percentage have the same number of labels to simplify the graph. I'm using pyplot module.
My failed attempt
I am trying to plot the graph through pandas but legend keeps on overlapping with the graph. I tried putting legend on the right side but it still showing with graph
I want to plot boxplots on top of the scattered points like this.
I know I have to bin the data into intervals first but I couldn't find the function that does all of this. Sample x and y data are saved here as .npy.
I would look into using matplotlib. Boxes can be drawn as such:
https://matplotlib.org/gallery/pyplots/boxplot_demo_pyplot.html?highlight=boxplot
and scatter plots can also be drawn as such: https://matplotlib.org/gallery/lines_bars_and_markers/scatter_demo2.html?highlight=scatter
There is a search functionality on their site, along with plenty of documentation on how to utilize their library.
As for your specific question, you can specify zorder when drawing many of the things in matplotlib, and you could use that to define your boxplots to be on top. I believe if no zorder is defined that it draws items in the order they are encountered in your program (so you could draw scatter plots and then box plots and they should appear correctly as in your diagram above!