Learn how to increase the ‘dimension’ of your plots.
Learn how to partition the gure using GridSpec.
Then I’ll talk about the process of creating advanced visualizations with
an example:
Set up a goal.
Prepare the variables.
Prepare the visualization.
Let’s start the journey.
TwodierentMatplotlibinterfaces
There’re two ways to code in Matplotlib. The rst one is state-based:
import matplotlib.pyplot as plt
plt.figure()
plt.plot([0, 1], [0, 1],'r--')
plt.xlim([0.0, 1.0])
plt.ylim([0.0, 1.0])
plt.title('Test figure')
plt.show()
Which is good for creating easy plots (you call a bunch of plt.XXX to
plot each component in the graph), but you don’t have too much
control of the graph. The other one is object-oriented:
import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=(3,3))
ax.bar(x=['A','B','C'], height=[3.1,7,4.2], color='r')
ax.set_xlabel(xlabel='X title', size=20)
ax.set_ylabel(ylabel='Y title' , color='b', size=20)
plt.show()
It will take more time to code but you’ll have full control of your gure.
The idea is that you create a ‘gure’ object, which you can think of it as
4.
5.
1.
2.
3.
评论0
最新资源