在Bokeh的Seaborn剧情的X轴标签

时间:2022-04-14 05:36:04

I'm attempting to follow the violin plot example in bokeh, but am unable to add x-axis labels to my violins. According to the Seaborn documentation it looks like I should be able to add x-axis labels via the "names" argument, however, the following code does not add x-axis labels:

我试图在散景中跟随小提琴情节示例,但我无法在我的小提琴中添加x轴标签。根据Seaborn文档,看起来我应该可以通过“names”参数添加x轴标签,但是,以下代码不会添加x轴标签:

import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from bokeh import mpl
from bokeh.plotting import show

# generate some random data
data = 1 + np.random.randn(20, 6)

# Use Seaborn and Matplotlib normally
sns.violinplot(data, color="Set3", names=["kirk","spock","bones","scotty","uhura","sulu"])
plt.title("Seaborn violin plot in Bokeh")

# Convert to interactive Bokeh plot with one command
show(mpl.to_bokeh(name="violin"))

I believe that the issue is that I'm converting a figure from seaborn to matplotlib to bokeh, but I'm not sure at what level the x-axis labels go in.

我相信问题在于我将一个数字从seaborn转换为matplotlib到散景,但我不确定x轴标签的位置。

I've confirmed that the labels are showing up in matplotlib before conversion to bokeh. I've also tried adding the labels to bokeh after conversion, but this results in a weird plot. I've created an issue for this problem with the bokeh developers here.

我已经确认标签在转换为散景之前出现在matplotlib中。我还尝试在转换后将标签添加到散景中,但这会导致一个奇怪的情节。我在这里与bokeh开发人员一起为这个问题创建了一个问题。

1 个解决方案

#1


Edit: I am not sure why the answer below was moved to a comment. Speaking as a project maintainer, this is the answer, namely: it is no longer possible to automatically convert Seaborn, as that feature is no longer part of the library. There is no other answer to give. It does no service to the project or to the user community to obscure this fact.

编辑:我不确定为什么下面的答案被移到评论。作为项目维护者,这就是答案,即:不再可能自动转换Seaborn,因为该功能不再是库的一部分。没有其他答案可以给予。它没有为项目或用户社区提供服务来掩盖这一事实。


Since Bokeh 12.5 (April 2017), support for Matplotlib has been deprecated, so mpl.to_bokeh() is no longer available.

自Bokeh 12.5(2017年4月)以来,对Matplotlib的支持已被弃用,因此mpl.to_bokeh()不再可用。

#1


Edit: I am not sure why the answer below was moved to a comment. Speaking as a project maintainer, this is the answer, namely: it is no longer possible to automatically convert Seaborn, as that feature is no longer part of the library. There is no other answer to give. It does no service to the project or to the user community to obscure this fact.

编辑:我不确定为什么下面的答案被移到评论。作为项目维护者,这就是答案,即:不再可能自动转换Seaborn,因为该功能不再是库的一部分。没有其他答案可以给予。它没有为项目或用户社区提供服务来掩盖这一事实。


Since Bokeh 12.5 (April 2017), support for Matplotlib has been deprecated, so mpl.to_bokeh() is no longer available.

自Bokeh 12.5(2017年4月)以来,对Matplotlib的支持已被弃用,因此mpl.to_bokeh()不再可用。