In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to use Python programming matplotlib drawing pick diamond seaborn violin and box diagram, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.
Seaborn is a supplement to matplotlib, provides a series of good-looking figure, and integrates a variety of online data sets, which can be called through sns.load_dataset () for learning. If the network is unstable, it can be downloaded locally, and then set cache to True when calling.
Among them, the diamonds data set contains diamond data, a total of ten items, namely [weight / carat] carat, cutting level cut, color color, transparency clarity, depth depth, table, price price and dimensions in x, y, z directions.
The first step in drawing is to import packages and data.
Import seaborn as snsimport matplotlib.pyplot as plt# locally loaded dataset dia = sns.load_dataset ("diamonds", data_home= "seaborn-data", cache=True) # the box diagram is not repeated after the above lines of code
Now we want to know the price range of the five cutting methods: Premium, Fair, Very Good, Good and Ideal, so the most direct idea is to make a box line diagram, which is similar to the K-line diagram.
In this diagram, the box and line describe five statistics: the minimum abnormal value, the first quartile (25%), the median, the third quartile (75%), and the non-abnormal maximum. The points above the maximum are outliers. It can be seen that diamonds worth more than $15000 are different.
> sns.boxplot (x = "cut", y = "price", data=dia,color='lightblue',fliersize=0.25) > plt.show ()
Where fliersize represents the size of the exception value.
Enhanced box diagram
Although the box chart can describe certain distribution characteristics, it is not enough. After all, there are only five statistics.
An enhanced version of the box chart is available in sns: boxenplot
In this diagram, the price range is divided, and in each price range, the wider the box, the more samples.
Sns.boxenplot (x = "cut", y = "price", data=dia, palette= "ch:rot=-.5,d=.3_r") plt.show () violin
If you want to be more detailed, you have to use a violin picture.
Sns.violinplot (x = "cut", y = "price", data=dia) sns.despine (left=True)
From this point of view, the price range of the best cut diamonds is about 1000, which is outrageous, but it is also very real.
Thank you for reading this article carefully. I hope the article "how to use Python programming matplotlib drawing to pick Diamond seaborn Violin and Box Diagram" shared by the editor will be helpful to everyone. At the same time, I hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
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: 0
*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.