我通过在 2 个窗口子图中绘制数据,能够在一组 4 个数据集之间切换每个图。每个数据集具有不同数量的迹线,并且迹线具有不同的长度名称。这是我的布局定义:
var layout = {
font: {
family:'Roboto',
size: 12,
color: 'rgb(54, 54, 54)'
},
yaxis: {title: "Temperature [C]",
domain: [0,.49],
mirror:'ticks',
showline:true,
linecolor: 'rgb(54, 54, 54)',
ticklen:3,
tickcolor: 'rgb(245, 245, 245)',
linewidth: 1}, // set the y axis title
yaxis2: {title: "Pressure [bara]",
domain: [.51,1],
mirror:'ticks',
showline:true,
linecolor: 'rgb(54, 54, 54)',
linewidth: 1,
ticklen:3,
tickcolor: 'rgb(245, 245, 245)'},
xaxis: {title: "Time (your current local time)",
mirror:'ticks',
showline:true,
linecolor: 'rgb(54, 54, 54)',
linewidth: 1,
tickformat: "%H:%M" …Run Code Online (Sandbox Code Playgroud) 我使用plotly 中的subplot 函数在我的R-shiny 应用程序中绘制两个图表(一个在另一个下)。图例对于这两个图来说都很常见,这意味着我只有一列将所有图例组合在一起。
我想在子图中将每个图表附近的图例分开。我怎样才能获得它?
p1 <-
iris%>%
group_by(Species)%>%
plot_ly(x=~Sepal.Length, color= ~Species, legendgroup=~Species)%>%
add_markers(y= ~Sepal.Width)
p2 <-
iris%>%
group_by(Species)%>%
plot_ly(x=~Sepal.Length, color= ~Species, legendgroup=~Species)%>%
add_markers(y= ~Sepal.Width)
subplot(p1,p2, nrows = 2, shareX = T, shareY = F, titleX = T, titleY = T)
Run Code Online (Sandbox Code Playgroud)
我正在尝试绘制具有特定颜色的直方图,因为目的是从两个不同的数据帧创建两个直方图,并且我不想将它们都显示为默认的蓝色。我知道解决方案意味着将 ggplo2 对象转换为plotly,但我想找到一种方法来解决plotly代码中的这个小问题。基本绘图直方图的代码如下:
plot_ly(x=~dataframe$variable, type="histogram") %>%
layout(title="Histogram title", xaxis=list(title="X-axis title"))
Run Code Online (Sandbox Code Playgroud)
我尝试过的两种解决方案均无效:
1)第一次尝试:
plot_ly(x=~dataframe$variable, type="histogram", color="green") %>%
layout(title="Histogram title", xaxis=list(title="X-axis title"))
Run Code Online (Sandbox Code Playgroud)
它返回以下警告消息:
In RColorBrewer::brewer.pal(N, "Set2") :
minimal value for n is 3, returning requested palette with 3 different levels
Run Code Online (Sandbox Code Playgroud)
2)第二次尝试:
plot_ly(x=~dataframe$variable, type="histogram", colour="green") %>%
layout(title="Histogram title", xaxis=list(title="X-axis title"))
Run Code Online (Sandbox Code Playgroud)
它返回以下警告消息:
'histogram' objects don't have these attributes: 'colour'
Valid attributes include:
'type', 'visible', 'showlegend', 'legendgroup', 'opacity', 'name', 'uid', 'ids', 'customdata', 'hoverinfo', 'hoverlabel', 'stream', 'x', 'y', 'text', 'orientation', 'histfunc', 'histnorm', 'cumulative', 'autobinx', 'nbinsx', 'xbins', …Run Code Online (Sandbox Code Playgroud) 我试图提供一个带有列名的变量来创建一个plotly图表,类似于ggplot2::aes_string. 不知怎的,我被困住了......
plot_ly(iris, x=~Sepal.Length, y=~Sepal.Width) # works as expected
plot_ly(iris, x=~'Sepal.Length', y=~'Sepal.Width') # fails since it doesn't use the column
Run Code Online (Sandbox Code Playgroud)
我想这是一个非常简单的问题,但我只是错过了寻找堆栈溢出解决方案的词汇。
我有大约200 x 200 x 200 x 150需要在浏览器上绘制的网格。
这可以表示为Xx Yx Zx Color。3D 散布通常具有此功能。
我已经尝试过plotly.Scatter3d对于较小的数据集来说效果很好。
我看了一下,Datashader但不幸的是只适用于 2D。我也检查了Datashader+Holoviews但没有找到任何解决方案......
我越接近的是来自 PlotLy 的 MRI Slice 示例:https://plot.ly/python/visualizing-mri-volume-slices/
如果有可能添加额外的切片器(X、Y 和 Z),这可能是一个解决方案。不是我想要的,而是一个解决方案。
任何如何实现这一目标的想法将不胜感激。谢谢
我需要使用plotly绘制我的数据,但是这段代码没有给我任何结果,我显示我的数据,但没有任何数字:
import plotly.graph_objs as go
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
data_t = []
for mac, dico_data in dict_info.items():
data_t.append(go.Scatter( x= dico_data['asn'], y= dico_data["time"], name=mac ))
print (data_t)
data = data_t
iplot(data_t)
Run Code Online (Sandbox Code Playgroud) 我想使用 TeX 来标记 3D 曲面图的轴。在 MathJax 的帮助下,我设法使用 TeX 作为标题。但不是轴。附件中包含我尝试做的示例。
x0 <- seq(1,100,by=0.1)
z0<-x0^2%*%t(x0)
library(plotly)
p <- plot_ly(
x = x0,
y = x0,
z = z0)%>%
add_surface() %>%
layout(
title = TeX("\\text{Graph of } f(x,y)=x^2*y"),
scene = list(
xaxis = list(title = "x"),
yaxis = list(title = "y" ),
zaxis = list(title = TeX("f(x,y)=x^2*y"))
))%>%
config(mathjax = 'cdn')
p
Run Code Online (Sandbox Code Playgroud)
结果如下
如何将 TeX 也用于轴标签?$\cdot$此外,无论如何我可以在标题中使用*?
在阅读了与此问题相关的所有现有帖子后,我仍然无法解决它。
ModuleNotFoundError: No module named 'plotly'
Run Code Online (Sandbox Code Playgroud)
我已尝试以下所有方法:
pip3 install plotly
pip3 install plotly --upgrade
Run Code Online (Sandbox Code Playgroud)
以及通过以下方式卸载:
pip3 uninstall plotly
Run Code Online (Sandbox Code Playgroud)
再次重新安装它,我在终端上得到以下信息:
Requirement already satisfied, skipping upgrade: six in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from plotly) (1.11.0)
Requirement already satisfied, skipping upgrade: nbformat>=4.2 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from plotly) (4.4.0)
Requirement already satisfied, skipping upgrade: retrying>=1.3.3 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from plotly) (1.3.3)
Requirement already satisfied, skipping upgrade: urllib3<1.25,>=1.21.1 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from requests->plotly) (1.24.1)
Requirement already satisfied, skipping upgrade: idna<2.8,>=2.5 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from requests->plotly) (2.7)
Requirement already satisfied, skipping upgrade: chardet<3.1.0,>=3.0.2 …Run Code Online (Sandbox Code Playgroud) 我试图返回一个条形图,但用于条形图的列根据下拉值选择而变化。我将字典返回到 graph.figure 输出,但收到以下错误;
dash.exceptions.InvalidCallbackReturnValue:
The callback for property \figure``
of component \graph-one` returned a value`
which is not JSON serializable.
In general, Dash properties can only be
dash components, strings, dictionaries, numbers, None,
or lists of those.
Run Code Online (Sandbox Code Playgroud)
我的返回值是一本字典。代码如下;
def create_grouped_bar(df):
return [
go.Bar(
x=df['date'],
y=df[col],
text=df[col],
hoverinfo='text+name',
name=col.title(),
)
for col in df.columns
]
@app.callback(
Output('graph-one', 'figure'),
[Input('filtered_df', 'children'),
Input('freq-radio', 'value'),
Input('graph-one-drop', 'value'),
Input('graph-one-radio', 'value')])
def update_graph(df_json, freq, cols, amount):
dff = pd.read_json(df_json, orient='split')
plot_cols = falls_dd_dict[cols]
plot_df = dff[['date_time_occurred']+plot_cols].copy() …Run Code Online (Sandbox Code Playgroud) 我有几个组的测量值,我想将它们绘制为小提琴图:
set.seed(1)
df <- data.frame(val = c(runif(100,1,5),runif(100,1,5),rep(0,100)),
group = c(rep("A",100),rep("B",100),rep("C",100)))
Run Code Online (Sandbox Code Playgroud)
使用R的ggplot2:
library(ggplot2)
ggplot(data = df, aes(x = group, y = val, color = group)) + geom_violin()
Run Code Online (Sandbox Code Playgroud)
R但是当我尝试使用's获得等效值时plotly:
library(plotly)
plot_ly(x = df$group, y = df$val, split = df$group, type = 'violin', box = list(visible = F), points = F, showlegend = T, color = df$group)
Run Code Online (Sandbox Code Playgroud)
“C”组获得一把充气/人造小提琴。
知道如何处理这个问题而不是使用 吗ggplotly?
plotly ×10
r ×5
python ×4
colors ×1
datashader ×1
histogram ×1
holoviews ×1
javascript ×1
latex ×1
plotly-dash ×1
python-3.x ×1
r-plotly ×1
subplot ×1
tex ×1
violin-plot ×1