boxplot ggplot python not filling boxes with colours - python

So im using the diamonds dataset and want to do a box plot of price and cut of the diamond using ggplot in python. This is the line of code to do the plot.
ggplot(aes('cut','price',fill='cut'),diamonds) +geom_boxplot()
However, boxes stay gray even though the color legend shows. This is the plot I get:
How can I make the boxes fill the colour in the legend??
Thanks very much!

Related

Plotly bar plot overlay colors getting mixed

I have a bar plot (python plotly) with two traces in blue and yellow (as shown by the legend), using the barmode='overlay' layout setting. But however when displaying the figure, these two colors get 'mixed' and it ends up being a dark purple color, which is confusing to the user as the legend does not show this mixed color. Is there any way to not mix the original colors with barmode='overlay'?

Matplotlib.savefig ignoring axes and plotting black border around image

I have a matplotlib Figure embedded in a QtAggFigureCanvas (PyQt4) with titles and axis labels (example shown below).
I implemented a button to save the figure to a png file. The figure was created with:
self.plkDpi = 100
self.plkFigure = Figure(dpi=self.plkDpi)
...
self.plkAxes = self.plkFig.add_subplot(111)
...
self.plkAxes.set_xlabel(...)
self.plkAxes.set_ylabel(...)
self.plkAxes.set_title(...)
When I hit my save button, the following code is executed:
self.plkFig.savefig('tmp.png', bbox_inches='tight', dpi=self.plkDpi)
For some reason, the axes and plot title are omitted from the final plot. But they are not cropped - there is a bounding black box around the figure that is just blank (see below)
No matter what I try, changing figsize, dpi, bounding box, etc. I cannot get the figure to save with the axis labels.
Please, take a look at this link: Black background behind a figure's labels and ticks, only after saving figure but not in Python Interactive view (VS Code with Jupyter functionality)?.
It seems plt.savefig() overwrites plot parameters. So you must define them again. Try this: plt.savefig('yourfilenamehere.png', facecolor='w'). This will set the borders in white.
Best regards,

how to avoid color overlap for matplotlib

I am trying to plot multiple data in one plot with matplotlib. Part of the data will overlap with each other. When I plot the graph, the overlapped areas produce different colors as shown in this graph
Is there a way to prevent the overlapped area to produce extra color in matplotlib. The graph I want to plot is like this graph
Thank you for your help.

contour plot matplotlib on a specific background color

I am generating contour plots (with transparent background) for pH of water on a river, and am overlaying the generated plot on the interactive map using map box. It looks like this:
I want to overlay plot in only on the water area, and not show over the ground area.
In my understanding there should be two ways possible:
1. While generating the image, making that part invisible
2. While overlaying the image, making that part invisible
I have tried finding solution for both but couldn't get a solution. Is there any way to go about it?

Different colours for different boxes for box plot generated by matplotlib

I am using matplotlib in Python to generate box plot. I want to make different boxes in different colours. Is there a way to do that?
Figure

Categories

Resources