- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我在 pandas DataFrame 中有时间序列数据,我想为这些行设置单独的标记。到目前为止,我只能通过使用 marker='o'
参数为两行使用相同的标记。
我正在使用 http://stanford.edu/~mwaskom/software/seaborn/tutorial/timeseries_plots.html#specifying-input-data-with-long-form-dataframes 中的示例我复制并粘贴了下面的代码。
如何为每条线绘制单独的标记?
import numpy as np
np.random.seed(9221999)
import pandas as pd
from scipy import stats
import matplotlib.pyplot as plt
import seaborn as sns
sns.set(palette="Set2")
def gamma_pdf(x, shape, coef, obs_err_sd=.1, tp_err_sd=.001):
y = stats.gamma(shape).pdf(x) * coef
y += np.random.normal(0, obs_err_sd, 1)
y += np.random.normal(0, tp_err_sd, len(x))
return y
gammas = []
n_units = 20
params = [(5, 1), (8, -.5)]
x = np.linspace(0, 15, 31)
for s in range(n_units):
for p, (shape, coef) in enumerate(params):
y = gamma_pdf(x, shape, coef)
gammas.append(pd.DataFrame(dict(condition=[["pos", "neg"][p]] * len(x),
subj=["subj%d" % s] * len(x),
time=x * 2,
BOLD=y), dtype=np.float))
gammas = pd.concat(gammas)
sns.tsplot(gammas, time="time", unit="subj",
condition="condition", value="BOLD", marker="o")
plt.show()
最佳答案
您必须对 condition
变量的每个级别调用 tsplot
两次,或者您可以这样绘制,然后对绘图数据:
ax = sns.tsplot(gammas, time="time", unit="subj",
condition="condition", value="BOLD", marker="o")
ax.lines[-1].set_marker("s")
关于python - 如何使用 tsplot 设置多个标记?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27986268/
我有以下数据框: Date group count 0 2015-01-12 Category1 27 1 2015-01-19 Category1 2 2
我有一个时间序列,其中统一样本保存到一个 numpy 数组,我想用自举置信区间绘制它们的平均值。通常,我使用 Seaborn 的 tsplot 来完成此操作。但是,现在是being deprecate
我想在 tsplot() 中显示标准差,而不是平均值的标准误差。看起来 'ci_band' 选项显示的是后者。 如果这是可能的,有谁知道如何实现这一点的任何例子吗? 最佳答案 2015-11-14 不
我认为这一定与缺少单位/我的单位没有连续编号有关。 我有一个 df,其批处理 ID 是在不同年份测量的,但许多批处理 ID 只在一年(也许两年)内出现。 我仍然想绘制样本随时间的发展情况。 有什么解决
我正在运行以下代码并遇到此问题 - "/usr/local/lib/python2.7/dist-packages/seaborn/timeseries.py:183: UserWarning: Th
我有一个名为 amounts_month 的数据框,属于这种类型: product accounting_month amount 0 A 201404
我想在 Seaborn 中为 tsplot 的下半部分着色。我有以下代码: sns.tsplot(时间=时间,数据=数据) 是否可以为绘图的下部区域着色?我尝试使用 barplot,但我的数据太大,所
我正在尝试使用 seaborn 制作一个简单的 tsplot,但由于我不清楚的原因,当我运行代码时没有任何显示。这是一个最小的例子: import numpy as np import seaborn
我在 pandas DataFrame 中有时间序列数据,我想为这些行设置单独的标记。到目前为止,我只能通过使用 marker='o' 参数为两行使用相同的标记。 我正在使用 http://stanf
我想创建一个 tsplot,其中 x 轴和 y 轴的长度相同。换句话说,图形的纵横比应为 1。 这是行不通的: fig, ax = plt.subplots() fig.set_size_inches
Seaborn's tsplot不像其他一些绘图类型(例如,lmplot)那样提供 size 选项。我知道这是因为 tsplot 是轴级函数,而 lmplot 是图形级函数。 问题: 我真的只是想要一
我正在尝试使用 tsplot 可视化 Gillespie 算法,但是这些点没有连接,因为每个重复和处理的时间点集都不同。有没有什么办法解决这一问题?这是我更改时间点的 gammas 示例代码: imp
我想使用 matplotlib 和 seaborn 创建一个平滑的折线图。 这是我的数据框df: hour direction hourly_avg_count 0 1
我正在尝试使用 seaborn 的 tsplot 函数,但它没有显示输出。相反,我收到一个错误: gammas = sns.load_dataset('gammas') sns.tsplot(time
我正在向 tsplot 传递一个列表列表(比如每个列表中有 31 个项目),它显示 0 到 31 的 x 轴标签。 我怎样才能让它显示 -15 到 15? 示例来自 the tutorial ,如果有
我有一个示例数据框 here (它是 df 的 pickle)。当我执行以下操作时: df = pd.read_pickle('test.pickle') sns.tsplot(data=df.sor
下面我有以下脚本,它创建了一个简单的时间序列图: %matplotlib inline import datetime import pandas as pd import seaborn as sn
我正在尝试 reshape 数据,如下所示: t y0 y1 y2 0 0 -1 0 1 1 1 0 1 2 2 2 1 2 3 3 3 2
我正在尝试在 seaborn 中使用 tsplot 在 FacetGrid 中绘制时间进程数据。我有两个实验,“A”和“B”,每个实验都有两个人(bob 和 joe)的时间过程测量,三个重复。我希望网
我想制作一张很像下面的图片: 我想使用 seaborn 使图表看起来漂亮,并让我自己以后更容易使用 facetgrids(我有十个不同的数据集,我想在同一个图表中显示。) 我在 seaborn 中找到
我是一名优秀的程序员,十分优秀!