matplotlib
Stacked bar plot in matplotlib
Create a stacked bar plot in matplotlib based on your data. You can plot only one stacked bar plot in one figure. You can select color, width, alignment and transparency (alpha).
Please check Advanced options to change plot style, set title, axis labels and control legend visibility and position.
matplotlibbarstacked
Required packages
You need below packages to use the code generated by recipe. All packages are automatically installed in MLJAR Studio.
matplotlib>=3.8.4
Interactive recipe
You can use below interactive recipe to generate code. This recipe is available in MLJAR Studio.
In the below recipe, we assume that you have following variables available in your notebook:
- X (type DataFrame)
Python code
# Python code will be here
Code explanation
- Please select DataFrame.
- Please select columns for x axis.
- You can customize color, transparency(alpha), width and alignment of every bar at once.
- Please check Advanced options.
- You can set title and axis labels there.
- If you would like to control position of legend in your plot, you can do this in Advanced options. The default value is best, which means that matplotlib will search for position that do not overlay chart points.
- You can apply different style for stacked bar figure.
Matplotlib cookbook
Code recipes from Matplotlib cookbook.
- « Previous
- Bar plot
- Next »
- Scikit-learn