In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article shows you what Python data visualization means, the content is concise and easy to understand, it will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
Disclaimer: since most of the code in this article is from the reference book, it does not provide complete code, only sample fragments, that is, you can only see a certain part of the usage, and those who are interested need to learn and test on their own data.
In the beginning, of course, we have to import the packages we need:
1. Draw a scatter plot
Scatter plots are plotted with plt.scatter (xrem y). Drawing a continuous curve, as you can see in the next example, uses plt.plot (XMagne y).
Plt.xticks (loc,label) can customize the display of the x-axis scale, and the * * parameters represent the position loc displayed by the second parameter label.
Plt.autoscale (tight=True) can automatically adjust the scale of the image display.
Draw the scatter plot as follows:
two。 The polynomial is going to be merged to draw the fitting curve.
# # polynomial fitting
Effect picture:
3. Draw multiple subgraphs
Sklearn's iris_dataset (Iris data set) is used here.
This dataset contains four columns, which are the four characteristics of Iris:
Sepal length (cm)-Calyx length
Sepal width (cm)-Calyx width
Petal length (cm)-petal length
Petal width (cm)-petal width
Here, first of all, the data are processed, mainly by pairwise arrangement and combination of the feature names, and then any two features, one doing the x-axis and the other doing the y-axis drawing.
Here is a reference code for permutation and combination. * is the case in which pairwise combinations are taken out.
The result of permutation and combination is that feature_names_2 contains all the cases of permutation and combination, and each element of it contains all the cases of a permutation and combination, such as the case where * elements contain all the permutation and combination of individual elements, and the second element contains all the cases of pairwise combination. So here's the second element, that is, all the pairwise combinations.
Here is how to draw multiple subgraphs in a for loop. For me, there is a lot to learn here. such as
For iJournal k in enumerate (feature_names_2 [1]): this sentence is always hard to remember.
For example, the method of fetching the index of an element from a list: index1 = feature_names.index (k [0]), in the form of index = list.index (element).
For example, the method of drawing subgraphs in the for loop: plt.subplot.
For example, the following usage of the for loop: for t ox Mark in zip (range (3), "> ox", "rgb"):
The visualization here is as follows:
4. Draw horizontal and vertical lines
For example, in the picture above, we have found a way to separate three kinds of irises. This is what we need to draw a model (a straight line). How do you draw at this time?
The next thing to pay attention to is the use of plt.vlines (x-maths) and plt.hlines (y-maths).
The visualization results are as follows:
5. Dynamic drawing
Plt.ion () turns on interactive mode. Plt.show () no longer blocks the program from running.
Note the use of plt.axis ().
Visualization:
What does the above content mean by Python data visualization? have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 278
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.