简体   繁体   English

如何在R中绘制密度图和线图

[英]How to Plot density graph and line graph in R

I'm having a big data-set in that three columns are there from those three columns I have to group-by the data by first columns and using the frequency of the first columns I need to plot the Line graph and Density graph. 我有一个大数据集,因为那三列中有三列,我必须按第一列对数据进行分组,并使用第一列的频率来绘制线图和密度图。 There are 1600 values counted in this graph. 此图中有1600个值。

some set of data are 一些数据是

Search keyword                         Campaign ID  total_ctr
        "2 +bhk +flat +in +bangalore    653435194   0.00
        "2 +bhk +flat +in +bangalore    653435194   0.00
        "2 +bhk +flat +in +bangalore    653435194   0.00
        "2 +bhk +flat +in +bangalore    653435194   0.00
        "2 +bhk +flat +in +bangalore    653435194   0.00
        "2 +bhk +flat +in +bangalore    653435194   0.00
        "2 +bhk +flat +in +bangalore    653435194   0.00
        "2 +bhk +flat +in +bangalore    653435194   0.00
        "2 +bhk +flat +in +bangalore    653435194   15.38
        "2 +bhk +flat +in +bangalore    653435194   0.00
        "2 +bhk +flat +in +bangalore    653435194   0.0
  +bedroom +apartment +in +bangalore    1155466985  0.00
+1 +bedroom +apartment +in +bangalore   1155466985  0.00
+1 +bedroom +apartment +in +bangalore   1155466985  0.00
+1 +bedroom +apartment +in +bangalore   1155466985  100.00
+1 +bedroom +apartment +in +bangalore   1155466985  0.00
+1 +bedroom +apartment +in +bangalore   1155466985  0.00

Like this the data set is goes for 22,200 lines and have 1600 search keyword have diffrent combination of total_ctr and campID. 像这样,数据集用于22,200行,具有1600个搜索关键字,具有total_ctr和campID的不同组合。

some of thier frequency are 他们的一些频率是

                                 Campaign ID     total_ctr
Search keyword      
"2 +bhk +flat +in +bangalore            24       24
+1 +bhk +flat +in +bangalore            89       89
+1 +bhk +flat +near +manyata tech park  23       23
+1 +bhk +flat +price +in +bangalore     15       15
+1 +bhk +flat +sale +bangalore           9       9
+1 +bhk +flats +bangalore               52       52
+1 +bhk +for +sale +in +bangalore       76       76
+1 +bhk +house +for +sale +in +bangalore20       20
+1 +bhk +in +bangalore +sale            61       61
+1 +bhk +in +north +bangalore           36       36
+1 +bhk +near +airport                  1         1
+1 +bhk +north +bangalore                8        8
+1bhk +apartment +in +bangalore         53       53
+1bhk +apartments +bangalore             9       9
+1bhk +bangalore                        118      118
+1bhk +flat +bangalore                   26       26
+1bhk +flats +bangalore                 107       107
+1bhk +near +airport                      4       4
+2 +3 +bhk +flats in +bangalore          50        50

From this frequency I want to plot 1600 plot in line and density graph in R or pandas 从这个频率我想在R或熊猫中以线图和密度图绘制1600个图

for i in df['Search keyword'].unique():
    xxx = df[df['Search keyword']==i]['total_ctr']
    jj =len(xxx)
    if jj>>29:
        print(jj)
        plt.plot(xxx)
        plt.title(i)
        plt.show()
        sns.kdeplot(xxx)
        plt.title(i + 'density')
        plt.show()
        plt.savefig('books_read.pdf')

This graph is only for density which you needed.. 该图仅用于您需要的密度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM