【发布时间】:2020-03-16 12:56:49
【问题描述】:
是否可以将单个值绘制为散点图? 我可以通过获取带有标记的 ccdfs 来很好地绘制它,但我想知道是否有任何替代方案可用?
输入:
输入 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 的散点图代码。但是在单值的情况下呢?
当所有输入合并为一个输入并按col[3] 分组时,值为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)
样本输出
【问题讨论】:
-
对于 scetterplot 你必须说你想要什么作为 x 轴和 y 轴。或者,您可能有一个
barplot具有类别/等。名称为 x 轴。 -
是的,很明显需要散点图 x 和 y。但在这种情况下,我将单变量数据作为不同类别的输出。线和条很常见。我正在努力寻找更好的可视化类型。
-
@MaxU 不绘制条形图的另一个原因是输入范围为 1 到 1000 个值
-
您将拥有多少个不同的类别?我不是询问价值观...
-
可能是swarmplot?
标签: python pandas matplotlib seaborn bokeh