The art of managing charts
It's important to draw an attractive chart. When you explore a data set, you need to draw a chart. It's a pleasure to see a chart. Visualization is just as important when communicating with your audience, and it's also necessary to draw attention to the chart and print it into your mind. Matplotlib has a high degree of automation, but it is quite difficult to master how to set up the system to obtain an attractive diagram. To control the look and feel of the Matplotlib diagram, the
Seaborn module comes with many custom themes and advanced interfaces.
%matplotlib inline
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
np.random.seed (sum(map(ord, "aesthetics")))
Let's first define a function to draw a sine function, which will help us understand the different styles of parameters we can control
def sinplot(flip=1):
x = np.linspace (0, 14, 100)
for i in range(1, 7):
plt.plot (x, np.sin (x + i * .5) * (7 - i) * flip)
By default, the map drawn by Matplotlib is as follows:
To convert to Seaborn module, only Seaborn module needs to be introduced.
import seaborn as sns
sinplot()
Seaborn's default light gray background and white network line are inspired by Matplotlib, but they are more soft than Matplotlib. We find that network lines are very useful for spreading information. In almost all cases, people like charts more than tables. By default, the form of a white gray grid avoids being too harsh. In the case of multi-faceted mapping, the network form is quite advantageous, providing a mapping structure, which is very important for some complex tools in the module.
Seaborn divides the parameters of Matplotlib into two groups. The first group controls the style of the chart and the metric elements of the chart, so that it can be easily incorporated into different contexts.
Two functions provide the interface to manipulate these parameters. Control styles with axes_ Style() and set_ Style () these two functions. Plotting for metric graphs_ Context () and set_ Context () are two functions. In both cases, the first set of functions returns a series of parameters, and the second set the default property of Matplotlib.
Figure style function axes_ Style() and set_ style()
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.