Line plot in matplotlib
Create a line plot in matplotlib based on your data. You can plot several series of lines in one figure. For each series, you can select color and transparency (alpha). Please provide label for line to create legend. You can also produce line plot with colors assigned to selected categorical column. 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 color and transparency for each plot. There can be several lines in the plot.
- You can color points on the line based on categorical column from your DataFrame. Please check all options on Color widget.
- 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 line figure.
Matplotlib cookbook
Code recipes from Matplotlib cookbook.
- « Previous
- Scatter plot
- Next »
- Bar plot