A library for drawing Python graphs. .. Positioned as a wrapper function (inclusive program) of matplotlib, the most famous libra. In addition to being able to easily draw beautiful-looking graphs, it also has a certain amount of functions such as batch processing. Matplotlib is for detailed specification and drawing, and seaborn is for easy and beautiful.
The theme this time is a scatter plot. Use jointplot
to create a scatter plot.
In the seaborn scatter plot, the histogram is displayed at the same time as the scatter plot. This is also convenient for grasping the data, and it looks like it and is quite good.
First, install the seaborn
library with pip. For pip ?, click here ('https://qiita.com/Yanagawa_Yoshihisa/items/35e6f70a8411277282ce').
Import the library. Name seaborn`` sns
and ʻimport`.
python
import seaborn as sns
I will try the sample with Titanic data. If you don't know Titanic, please check "kaggle Titanic". Create a data frame with pandas.
python
dataframe = pd.read_csv('train.csv')
Use .jointplot
to create a scatter plot. Basically, the items to be set are the X-axis item, Y-axis item, and the original data. Take an example of a graph that displays Age on the X-axis and Fare on the Y-axis.
As shown in the figure, the point is that it has a histogram.
python
sns.jointplot('Age', 'Fare', data=dataframe)
As you can see by looking it up, there are various options.
If you specify 'hex'
for kind
, the scatter plot will be on the tile and will be fashionable. It is recommended because it looks good.
(It is difficult to convey the original data because it is not good enough.)
python
sns.jointplot('Age', 'Fare', data=dataframe, kind = 'hex')
It's a very simple syntax, but it's recommended for those who aren't familiar with it because it looks like it and gives a feeling of doing it.
As even beginners can understand, we have summarized the necessary knowledge when implementing machine learning with Python as a simple article. The table of contents is here, so I hope you can refer to other articles as well.
Recommended Posts