I am using plotly to show an image using fig=px.imshow(img)
I would like it to have a discret legend similar to the ones in the pie chart or the bar chart: fig2 = px.pie(df, values=df[0],names=df.index,color =df.index, color_discrete_map= h.colormap)
imshow() does not have the argument color_discret_map but maybe there could be a work-around ?
I know it is possible with matplotlib but I need plotly to do it.
Related
I have a sunburst chart in plotly express. And I need the SVG of the chart. However, I can only write_image for the original chart, not any levels of drill down. Is there any way I could also export the drilled down sunburst chart?
I am trying to add colorbar for each subplot. The 3D data is like (x,y,z). My codes are like:
fig,ax = plt.subplots(2,2,figsize=(15,15))
ax[0,0].scatter(x,y,s=z,c=z,cmap='jet')
ax[0,0].set_xlabel('XXX')
ax[0,0].set_ylabel('YYY')
So I am able to add x,y labels, add title for each subplot, but I just can't add the colorbar.
My codes for colorbar in a single plot are like:
plt.colorbar(extend='both')
or
colorbar = plt.colorbar(label='test',orientation='horizontal',shrink=0.8,pad=0.05,extend='both')
I saw the previous Q&A here matplotlib colorbar in each subplot, but sorry I don't understand how to apply to my case. Is there a way to add the colorbar, just like how I added the xlabel and title, please? Many thanks.
In Bokeh 0.12.2, I was able to make a stacked bar chart with various hover tooltips using plotting and VBars. I also enabled a legend for the plot. However, my vbars are colored and the colors for each vbar (each stack) are not appearing in the legend. Only the names for the stack in the legend are appearing. Is this not an implemented feature yet or a bug maybe? Or maybe I'm missing something?
what my chart looks like
This was due to a bug in the bokeh source code which is being fixed if not fixed already.
Hi I don't know if this is possible, but I have made a bar plot in python where the color is a hex value. If I have the value that a hex code corresponds to, is it possible to make a colorbar for my bar plot in python? Or is there a way to use a colormap for bar plots in python?
This is my image right now. The color corresponds to a value, and I want to add a colorbar that has a range of colors with the value it will be. I have done this for scatter plots but I did not use a color map but just hex values for each bar.
Matplotlib does support colobars. Here's the API:
http://matplotlib.org/api/colorbar_api.html
Here's a code sample of a colorbar associated with a plot:
http://matplotlib.org/examples/pylab_examples/colorbar_tick_labelling_demo.html
EDIT:
Specifically to a bar plot, you could use a LinearSegmentedColormap instead of a colorbar, as in here
I would like to plot multiple pie charts over an existing plot using absolute coordinates.
I went through the add_axes method and also the AxesGrid toolikt but couldn't find a solution.
To be more specific, I want to draw pie charts over a geographical map using the basemap module.
This tutorial explains how to use matplotlib Basemap for drawing pie charts on a map. It is fairly simple and gives code examples.