小编Jai*_*oln的帖子

使用 Altair 交互式绘图时出现编码错误?

我正在尝试使用以下数据df_roc来使用 Altair 绘制 ROC 曲线:

    Threshold   TPR     FPR
0   0.1     1.000000    0.941176
1   0.2     1.000000    0.705882
2   0.3     0.923077    0.588235
3   0.4     0.846154    0.470588
4   0.5     0.692308    0.352941
5   0.6     0.615385    0.235294
6   0.7     0.461538    0.117647
7   0.8     0.307692    0.058824
8   0.9     0.076923    0.000000
Run Code Online (Sandbox Code Playgroud)

这是我尝试使用的代码来制作交互式绘图:

base = alt.Chart(df_roc, 
                 title='ROC Curve of KNN'
                ).properties(width=300)

roc_curve = base.mark_line(point=True).encode(
    alt.X('fpr', title='False Positive Rate (FPR)',  sort=None),
     alt.Y('tpr', title='True Positive Rate (TPR) (a.k.a Recall)'),
)

roc_rule = base.mark_line(color='green').encode(
    x='fpr',
    y='fpr',
    size=alt.value(2)
)


(roc_curve …
Run Code Online (Sandbox Code Playgroud)

python encoding altair

6
推荐指数
1
解决办法
8510
查看次数

如何在 Altair 中调整比例范围?

使用 altair 制作一组像这样的图时,我无法将所有轴都设置为相同的比例:

class_list = ['c-CS-m','c-CS-s','c-SC-m','c-SC-s','t-CS-m','t-CS-s','t-SC-m','t-SC-s']
list_of_plots = []

for class_name in class_list:
    list_of_plots.append(alt.Chart(data[data['class'] == class_name]).mark_bar().encode(
    x = alt.X('DYRK1A', bin = True, scale=alt.Scale()),
    y = 'count()').resolve_scale(
    y='independent'
))

list_of_plots[0] & list_of_plots[1] | list_of_plots[2] & list_of_plots[3] | list_of_plots[4] & list_of_plots[5] | list_of_plots[6] & list_of_plots[7]

Run Code Online (Sandbox Code Playgroud)

我想让 x 轴从 0.0 运行到 1.4,y 轴从 0 运行到 120,这样我制作的所有八个图都在相同的比例上!我尝试在当前空调用中使用域,Scale()但它似乎导致 x 轴数据从 0.0 到 0.3 的可视化被超级压缩,我不明白为什么?

对于上下文,我试图绘制蛋白质表达水平的连续值。这 8 个图针对暴露于不同条件的不同类别的小鼠。如果有帮助,可以在此链接中获取数据:https : //archive.ics.uci.edu/ml/datasets/Mice+Protein+Expression

如果我需要提供更多信息以便您帮助我,请告诉我!

python data-visualization altair

2
推荐指数
1
解决办法
4796
查看次数

标签 统计

altair ×2

python ×2

data-visualization ×1

encoding ×1