散点图上的标称/分类轴 [英] Nominal/categorical axis on a scatter plot

查看:96
本文介绍了散点图上的标称/分类轴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在散景中的散点图上生成标称/分类轴(像a, b, c而不是1,2,3这样的条目)?

How is it possible to generate a nominal/categorical axis (entries like a, b, c instead of 1,2,3) on a scatter plot in Bokeh?

想象一下应该绘制以下数据:

Imagine that the following data should be plotted:

a  0.5
b  10.0
c  5.0

我尝试了以下操作:

import bokeh.plotting as bk

# output to static HTML file
bk.output_file("scatter.html", title="scatter plot example")

x = ['a', 'b', 'c']
y = [0.5, 10.0, 5.0]

p = bk.figure(title = "scatter")
p.circle(x = x, y = y)
bk.show(p)

但是,这将生成一个空图.如果将x数据更改为x = [1, 2, 3],则将按预期绘制所有内容.

However, this generates an empty plot. If the x data is changed to x = [1, 2, 3] everything gets plotted as expected.

如何在x轴上放置a, b, c?

推荐答案

您需要明确提供类别列表作为x_rangey_range.参见:

You need to supply the list of categories as the x_range or y_range explicitly. See:

http://docs.bokeh.org/en/latest/docs/gallery/categorical.html

这篇关于散点图上的标称/分类轴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆