我的问题是剧情python情节方法
plot_url = py.plot(fig, filename='box-plot')
Run Code Online (Sandbox Code Playgroud)
自动启动Web浏览器,是否可以防止此行为?
谢谢你的回答!
我在r plotly中有一个水平条形图,我想给刻度标签更多的空间.请参阅以下示例:
libelle <- c("financial activities","Agriculture, sylviculture and fishing","Manufacture of transport materials","financial activities","Agriculture, sylviculture and fishing","Manufacture of transport materials")
value <- c(15000000,987000,154000000,10000000,927000,15400000)
annee <- c("2011","2011","2011","2012","2012","2012")
data <- data.frame(libelle,value,annee)
plot_ly(data=data,x=value,y=libelle,group=annee,type="bar",orientation="h")
Run Code Online (Sandbox Code Playgroud)
我看不到左边的标签,我也没有找到如何将垂直轴向右移动.
以下是我的代码,有人可以告诉我如何设置背景颜色,标题,x轴y轴标签:
scatterplot = plot([Scatter(x=x.index,
y=x['rating'],
mode='markers',
marker=dict(size=10,
color=x['value'],
colorscale='Viridis',
showscale=True),
text=(x['value'] + ' ' + x['Episode'] + '<br>' + x['label']))],
output_type='div'
)
Run Code Online (Sandbox Code Playgroud)
PS:这是直接显示在网页中。
我想自定义plotly绘图中的颜色.这适用于连续变量和按照文档进行缩放:
library(plotly)
plot_ly(iris, x = Petal.Length, y = Petal.Width,
color = Sepal.Length, colors = c("#132B43", "#56B1F7"),
mode = "markers")
Run Code Online (Sandbox Code Playgroud)
但是,如果我将参数设置为离散颜色(字符或因子),这仍然有效,但会发出警告:
> plot_ly(iris, x = Petal.Length, y = Petal.Width,
color = Sepal.Length>6, colors = c("#132B43", "#56B1F7"),
mode = "markers")
Warning message:
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)
我该怎么做呢?
我试图将一个单独的注释对象与Plotly(Python)中的每个子图关联起来,如何做到这一点?
我尝试了什么
我正在设置这样的情节:
from plotly import tools
fig = tools.make_subplots(rows=2, cols=1)
fig.append_trace(traces[0], 1, 1)
fig.append_trace(traces[1], 2, 1)
Run Code Online (Sandbox Code Playgroud)
每条迹线的形成方式如下:
import plotly.graph_objs as go
traces[0] = go.Scatter(
x=[1,2,3,4],
y=[4,4,2,1],
mode='markers'
)
Run Code Online (Sandbox Code Playgroud)
我知道我可以通过以下方式分别访问每个子图的xaxis:
fig['layout']['xaxis1'].update(title='hello1')
fig['layout']['xaxis2'].update(title='hello2')
Run Code Online (Sandbox Code Playgroud)
但是如何访问每个子图的注释?我试过"annotations1"和"annotation1",没有运气.我还尝试通过"layout1"访问子图1的布局,如下所示:
fig['layout1'][...].update(...)
Run Code Online (Sandbox Code Playgroud)
这也不起作用.
我有一个dataframe这样的:
line station var
1 a 39446
1 b 82964
1 c 57840
1 d 78946
1 e 69972
1 f 14303
1 g 78179
2 a 37738
2 b 62261
2 c 19378
2 d 76435
2 e 17181
2 f 75148
2 g 10882
Run Code Online (Sandbox Code Playgroud)
我想使用plot_ly从这些数据创建一个子图。我想要一个以station为x值,以var为y值的小节图。我想基于线有两个子图。我知道我可以这样做:
p1 <- plot_ly(data = df[df$line == "1", ], x = ~station, y = ~var, type = "bar")
p2 <- plot_ly(data = df[df$line == "2", ], x = ~station, y = ~var, …Run Code Online (Sandbox Code Playgroud) 我在Dash上的绘图遇到布局困难。我使用Dash生成的所有图似乎都自动调整为非常狭窄的大小,这使得在没有某些创意缩放的情况下很难实际查看数据。
例如,当我在其中一个破折号上查看源代码时,看起来它计算出主绘图容器(svg容器)的高度为450px,图形本身的高度为270px(查看子图) )。如果可以制作图表,例如700px,那就太好了。
我的问题是:在Dash上调整图表尺寸的最佳方法是什么?我的第一个猜测是以某种方式附加样式表,但是我不确定合适的CSS选择器如何或怎样。
谢谢!
我正在尝试使用绘制python中的分布图seaborn。但是我收到以下无法解决的错误。
码:
sns.distplot(df['nn'])
错误:
cannot convert float NaN to integer
是否有任何有效的方法可以通过绘制直方图和分布图来解决此问题?
我正在尝试在我的标题之一中用R / Plotly写出摄氏度符号。当我仅使用下面的简单绘图时,它就可以工作:
# Working code
library(latex2exp)
set.seed(1)
betas <- rnorm(1000)
hist(betas, main = TeX("Temperature (^0C)"))
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试通过代码运行代码时,出现以下错误:“'HashTableSetup'中未实现的类型'expression'。
#Initialise the plot
p <- plot_ly()
#Add axis names
#Font
f <- list(
family = "Courier New, monospace",
size = 18,
color = "#7f7f7f")
#X axis name
x <- list(
title = "x Axis",
titlefont = f)
#Y Axis name
y <- list(
title = TeX("Temperature (^0C)"),
titlefont = f)
#Add layout
p <- p %>%
layout(xaxis = x, yaxis= y)
p
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
我想plotly基于我的数据中的一列离散值来过滤使用创建的图表.最终目标是能够使用按钮来更新过滤器值,因此我不想事先过滤数据.
library(plotly)
df <- data.frame(group1 = rep(c('low', 'high'), each = 25),
x = rep(1:5, each = 5),
group2 = letters[1:5],
y = c(runif(25, 0, 2), runif(25, 3, 5)))
plot_ly(df, x = ~x, y = ~y, type = 'scatter',
mode = 'line',
color = ~group2,
transforms = list(
list(
type = 'filter',
target = ~group1,
operation = '=',
value = 'high'
)
)
)
Run Code Online (Sandbox Code Playgroud)
我希望这会给出以下图表:
但相反它给出了这个:
它似乎是在错误的变量上过滤.为什么不按照我预期的方式过滤数据?