码迷,mamicode.com
首页 > 其他好文 > 详细

Data Visualizations 7

时间:2016-10-15 07:42:25      阅读:137      评论:0      收藏:0      [点我收藏+]

标签:

1. If we create a DataFrame, each of the column inside of it is already a set of Series. Does not necessary to change them into a one-column Dataframe.

2. Here we use scatter_matrix function to plot the DataFrame:

  normal_movies = hollywood_movies[hollywood_movies["Film"] != "Paranormal Activity"]

  from pandas.tools.plotting import scatter_matrix #import scatter_matrix function from pandas.tool.plotting

  scatter_matrix(normal_movies[["Profitability","Audience Rating"]],figsize = (6,6)) #If we only put two columns into the scatter_matrix, we will get 4 plotting inside of the figure. it is a vs a, a vs b, b vs a, b vs b. a = "Profitability",     b = "Audience Rating".

3. In the following code, we plot cirtic rating and audience rating compare to a range which is generate automatically.

  normal_movies[["Critic Rating","Audience Rating"]].plot(kind = "box")

4.While we use seaborn.boxplot function, here is the example.

  normal_movies = normal_movies.sort_values("Year")

  fig = plt.figure(figsize=(8,4))

  yr1 = fig.add_subplot(1,2,1)
  yr2 = fig.add_subplot(1,2,2)

  sns.boxplot(x=normal_movies["Year"], y=normal_movies["Critic Rating"],ax = yr1)
  sns.boxplot(x=normal_movies["Year"], y=normal_movies["Audience Rating"],ax = yr2)
  plt.show()

output:

  技术分享

5. 

 Another way of using boxplot:

  normal_movies[‘Profitable‘]= normal_movies["Profitability"] >= 1
  fig = plt.figure(figsize = (12,6))
  ax1 = fig.add_subplot(1,2,1)
  ax2 = fig.add_subplot(1,2,2)
  sns.boxplot(data = normal_movies, x="Profitable",y ="Audience Rating",ax = ax1)
  sns.boxplot(data = normal_movies, x="Profitable",y ="Critic Rating",ax = ax2)

 

Data Visualizations 7

标签:

原文地址:http://www.cnblogs.com/kingoscar/p/5962691.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!