Customize Your Plot
Now we will look at how you can diversify and improve the presentation of your graphs. This will improve the perception of the graph and can also be useful when creating presentations and other documents with data analysis.
Let's start by adding headings to the graph:
plt.figure(figsize=(11, 9))
dataset.plot()
plt.title("HH spot price")
plt.show()
You can also change the style of the time series chart. If you want the graph to be not a solid line but consist of dots, then change the value of the linestyle argument to "dotted":
plt.figure(figsize=(11, 9))
dataset.plot(linestyle="dotted")
plt.title("HH spot price")
plt.show()
And finally, let's figure out how to change the chart's color scheme. You have a huge selection of colormaps, a complete list of which is on the official matplotlib
website.
To change the color palette, you just need to change the value of the colormap
argument to the name of the palette you are interested in:
plt.figure(figsize=(11, 9))
dataset.plot(label="dataset", colormap="cool")
plt.ylabel("Price")
plt.xlabel("Date")
plt.legend()
Swipe to start coding
Visualize the dataset pr_air_quality.csv
.
- Read the
csv
file. - Initialize a line plot for the
"value"
column ofdf
. Set"dotted"
linestyle
and"cool"
colormap
. - Add plot title
"Air quality analysis"
. - Add labels on the axis:
"Datetime"
on the x-axis and"Value"
on the y-axis.
Lösung
Danke für Ihr Feedback!
single
Fragen Sie AI
Fragen Sie AI
Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen
Awesome!
Completion rate improved to 3.85
Customize Your Plot
Swipe um das Menü anzuzeigen
Now we will look at how you can diversify and improve the presentation of your graphs. This will improve the perception of the graph and can also be useful when creating presentations and other documents with data analysis.
Let's start by adding headings to the graph:
plt.figure(figsize=(11, 9))
dataset.plot()
plt.title("HH spot price")
plt.show()
You can also change the style of the time series chart. If you want the graph to be not a solid line but consist of dots, then change the value of the linestyle argument to "dotted":
plt.figure(figsize=(11, 9))
dataset.plot(linestyle="dotted")
plt.title("HH spot price")
plt.show()
And finally, let's figure out how to change the chart's color scheme. You have a huge selection of colormaps, a complete list of which is on the official matplotlib
website.
To change the color palette, you just need to change the value of the colormap
argument to the name of the palette you are interested in:
plt.figure(figsize=(11, 9))
dataset.plot(label="dataset", colormap="cool")
plt.ylabel("Price")
plt.xlabel("Date")
plt.legend()
Swipe to start coding
Visualize the dataset pr_air_quality.csv
.
- Read the
csv
file. - Initialize a line plot for the
"value"
column ofdf
. Set"dotted"
linestyle
and"cool"
colormap
. - Add plot title
"Air quality analysis"
. - Add labels on the axis:
"Datetime"
on the x-axis and"Value"
on the y-axis.
Lösung
Danke für Ihr Feedback!
Awesome!
Completion rate improved to 3.85single