问题描述
是否可以将单个值绘制为散点图?通过使用带有标记的ccdfs,我可以很好地将其绘制出来,但是我想知道是否有其他选择可用?
Is It possible to plot single value as scatter plot? I can very well plot it in line by getting the ccdfs with markers but I want to know if any alternative is available?
输入:
输入1
tweetcricscore 51 high active
输入2
tweetcricscore 46 event based
tweetcricscore 12 event based
tweetcricscore 46 event based
输入3
tweetcricscore 1 viewers
tweetcricscore 178 viewers
输入4
tweetcricscore 46 situational
tweetcricscore 23 situational
tweetcricscore 1 situational
tweetcricscore 8 situational
tweetcricscore 56 situational
我可以使用x
和y
值用bokeh
和pandas
编写散点图代码.但是如果是单个值?
I can very much write scatter plot code with bokeh
and pandas
using x
and y
values. But in case of single value ?
将所有输入合并为一个输入并按col[3]
分组时,值将为col[2]
.
When all the inputs are merged as one input and are to be grouped by col[3]
, values are col[2]
.
下面的代码用于包含2个变量的数据集
import numpy as np
import matplotlib.pyplot as plt
from pylab import*
import math
from matplotlib.ticker import LogLocator
import pandas as pd
from bokeh.charts import Scatter, output_file, show
df = pd.read_csv('input.csv', header = None)
df.columns = ['col1','col2','col3','col4']
scatter = Scatter( df, x='col2', y='col3', color='col4', marker='col4', title='plot', legend=True)
output_file('output.html', title='output')
show(scatter)
样本输出
推荐答案
更新:
查看散景和 Seaborn 画廊-它可以帮助您了解哪种情节适合您的需求
look at Bokeh and Seaborn galleries - it might help you to understand what kind of plot fits your needs
您可以尝试像这样的violinplot:
you may try violinplot like this:
sns.violinplot(x="category", y="val", data=df)
或HeatMaps:
import numpy as np
import pandas as pd
from bokeh.charts import HeatMap, output_file, show
cats = ['active', 'based', 'viewers', 'situational']
df = pd.DataFrame({'val': np.random.randint(1,100, 1000), 'category': np.random.choice(cats, 1000)})
hm = HeatMap(df)
output_file('d:/temp/heatmap.html')
show(hm)
这篇关于单变量类别散点图 pandas 的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!