Scatter plot in matplotlib
Create a scatter plot in matplotlib based on your data. You can add plot several series of scatters in one figure. For each serie, you can select color, size and transparency (alpha). Please provide label for scatters to create legend. You can also produce scatter plot with colors assigned to selected categorical column. In this case, only first scatter is displayed.
Please check Advanced options to change plot style, set title, axis labels and control legend position.
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 and y axis. You can set colot, size and transparency for each scatter. There can be several scatters in the plot.
- You can color points in the scatter based on categorical column from your DataFrame. Please check all options on Color widget. In the case of coloring by value, only one scatter (the first one) can be displayed in the figure.
- Please check Advanced options.
- You can set title and axis labels there.
- If you wouldlike 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 scatter figure.
Example Python notebooks
Please find inspiration in example notebooks
Matplotlib cookbook
Code recipes from Matplotlib cookbook.
- « Previous
- Matplotlib
- Next »
- Line plot