- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试创建一个具有多个轴的绘图。但是,holoviews 不是将 Gene 和 db 放在 x 轴上,将突变放在 y 轴上,而是将 db 放在 y 轴上,将gene 放在 x 轴上。
我怎样才能从中得到多类别图?
mutated_positions = hv.Scatter(totaldf,
['gene', 'db'], 'mutations', xrotation=45).opts(size=10, color='#024bc2', line_color='#002869', jitter=0.2, alpha=0.5)
当前的情节如下所示: /image/jje5h.jpg我试图得到这样的轴: /image/GBziX.jpgY 轴上有突变。
我使用的数据框如下所示:
gene db mutations
0 IGHV1-3 G1K_CL2 6
1 IGHV1-58 G1K_CL2 2
2 IGHV1-58 G1K_CL2 3
3 IGHV1-8 G1K_CL2 2
4 IGHV3-16 G1K_CL2 3
.. ... ... ...
141 IGHV4-61 G1K_CL3 11
142 IGHV4-61 G1K_CL3 12
143 IGHV4-61 G1K_CL3 10
144 IGHV4-61 G1K_CL3 13
145 IGHV7-81 G1K_CL3 4
最佳答案
下面的代码是将突变放在 y 轴上,并将 db 和/或基因放在 x 轴上的一种方法。
它创建一个Ndlayout,这意味着为每个基因创建一个单独的图。
# import libraries
import pandas as pd
import holoviews as hv
from holoviews import opts
hv.extension('bokeh')
# create dataframe
data = [
['IGHV4-61', 'G1K_CL2', 11],
['IGHV4-61', 'G1K_CL3', 12],
['IGHV4-61', 'G1K_CL3', 10],
['IGHV7-81', 'G1K_CL2', 13],
['IGHV7-81', 'G1K_CL3', 4],
]
df = pd.DataFrame(data, columns=['gene', 'db', 'mutations'])
# create layout plot with mutations on the y-axis
layout_plot = hv.Dataset(df).to.scatter('db', 'mutations').layout('gene')
# make plot look nicer
layout_plot = layout_plot.opts(opts.Scatter(size=10, ylim=(0, 15), width=250))
# show structure of holoviews layout plot
print(layout_plot)
# show plot in Jupyter
layout_plot
情节结构如下:
:NdLayout [gene]
:Scatter [db] (mutations)
作为替代方案,您也可以使用构建在 Holoviews 之上的 hvplot 库,它会给您与上面相同的结果。这与 pandas 绘图基本相同,您可以使用 argument by='gene' 和 subplots='True' 来创建 Ndlayout。
# import libraries
import hvplot
import hvplot.pandas
hv.extension('bokeh')
# create layout plot with hvplot
layout_plot = df.hvplot(
kind='scatter',
x='db',
y='mutations',
by='gene',
subplots=True, # creates a layout
size=100, # marker size
ylim=(0, 15),
width=250, # width of plot
)
# show structure of holoviews layout plot
print(layout_plot)
# show plot in Jupyter
layout_plot
关于python - 将 Holoviews 轴更改为正确的格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58030186/
我有一个表格数据集,它有多个列,可能是某些绘图的关键维度。 ds = hv.Dataset(data_df, kdims=['time', 'forecasttime', 'group'], vdim
在 bokeh Holoviews 画廊中,有一个名为“Scatter economic”的示例。 http://holoviews.org/gallery/demos/bokeh/scatter_e
我想将全息图保存为 SVG,但是我收到一条我不明白的错误消息: np.random.seed(9) data = np.random.rand(10, 2) points =
我正在使用 Holoviews 构建图表仪表板。其中一些图表在 y 轴上有百分比,而其他图表有总和/计数等。当我尝试将我创建的所有图表输出到 html 文件时,所有图表都会更改它们的 y 轴以匹配第一
我正在尝试使用 Holoviews 绘制热图。我做了几次尝试但没有成功。我绘制的数据有 2 个值(一个在“x”轴上,一个在“y”轴上),我希望每种颜色代表数量(就像热图中的直方图)。 最佳答案 在 H
我在 Bokeh 之上使用全息 View 创建了一个热图 import numpy as np import pandas as pd import holoviews as hv from holo
这是代码: import pandas as pd import holoviews as hv hv.extension('bokeh','matplotlib','plotly') mydf =
我这里有一个非常简单的例子: plot = [] for d in range(2): name=str(d) data = pd.DataFrame({'x':[2,5,1], 'y
我希望曲线的用户能够从 slider (斜率)调整曲线,但我希望斜率的值返回一组不同的值。 这样,如果用户选择 1,曲线将使用值 0.5,如果用户选择 5,曲线将使用值 0.8。 我尝试使用 lamb
我一直在尝试了解如何完成绘制两个数据集(每个数据集具有不同颜色)这一非常简单的任务,但我在网上发现的任何内容似乎都无法做到这一点。这是一些示例代码: import pandas as pd impor
我目前正在拼命尝试在网格状布局中对齐三个不同大小的图像。 本质上,我想插入三个不同形状的光栅图像。我希望能够独立定义每个栅格的边界和纵横比,使它们不会在一维上拉伸(stretch)。但是,我找不到这样
我正在尝试更改数据着色器使用的颜色图。 我试过这个: datashade(scatter, cmap='Reds') 其中 scatter 是一个 hv.Scatter 元素。这是行不通的,因为数据着
由于我处理的数据量很大,我使用 Datashader 制作不同参数的交叉图。我的想法是启用某种交互,允许用户直接从图中选择,基于数据趋势的异常值显示了这些。我想知道 Holoviews Selecti
我看到有关如何在全息 View 中编辑单个对象(如图像或直方图)的范围(又名轴限制)的示例 such as this answer on stack exchange for histogram ex
我正在尝试在 Holoviews 中为每个点生成一个具有自定义颜色值的热图,以便指定不同的 alpha 颜色值。 目前我正在生成两个具有不同 alpha 值的 Holoviews 图并像这样叠加它们:
我有一个带有两个静态 HLine 的条形图,我想为它们添加标签(或图例),以便在图上定义它们。我试过类似的东西: eq = ( sr2.hvplot( kind="bar",
我正在学习带有 Bokeh 后端的 HoloViews,并且正在制作 Pandas 数据帧所选列的 iPython/Jupyter 显示(实际上它是一个 xarray 数据集,但用数据帧显示问题更简单
有没有办法在 Holoviews 中将绘图旋转 90°? 我有兴趣知道一般如何做到这一点,但我的直接目的是生成一个直方图,该直方图被旋转以将频率放在水平方向上,将关键值放在垂直方向上,以布局在散点旁边
是否有某种方法可以设置在 HoloViews 中组成的各个绘图的范围或边界?我试图使用下面的代码同时显示图像和线图。如果我如下所述设置图像的边界,我似乎无法修改线图的范围;后者以轴 x = (0, 1
我是 Holoviews/bokeh 的新手,我对如何构建图表有了大致的了解,但我仍然迷失在一些细微差别中,并且发现文档中的示例非常有限。 有了分类数据的时间序列,我尝试呈现多个堆叠条形图,这些条形图
我是一名优秀的程序员,十分优秀!