表盘位置规图P [英] Dial Position Gauge Chart Plotly R
问题描述
这个问题似乎已经以一种或另一种方式被问过几次,但我似乎不太能找到正确的答案.我正在尝试在plotly
仪表图上移动中心刻度盘.我正在使用提供的演示( https://plot.ly/r/gauge-图表/),而我也正在使用本文中的指南(
This question appears to have been asked a couple of times in one fashion or another, but I can't quite seem to find the correct answer. I'm trying to move the center dial on a plotly
gauge chart. I'm using the demo that has been provided (https://plot.ly/r/gauge-charts/), and I'm also using guidance from this post (How to rotate the dial in a gauge chart? Using python plotly) - although it's python
and not r
.
我对SVG的体验绝对为零,我敢肯定,您可以说.任何帮助将不胜感激.
I have absolutely zero experience with SVG- as I'm sure you can tell. Any help would be greatly appreciated.
h = 0.24
k = 0.5
r = 0.15
my_raw_value = 100
theta = my_raw_value * 180/300
theta = theta * pi / 180
x = h + r*cos(theta)
y = k + r*sin(theta)
path = paste0('M 0.235 0.5 L ' ,str(x) , '', str(y),' L 0.245 0.5 Z')
base_plot <- plot_ly(
type = "pie",
values = c(40, 10, 10, 10, 10, 10, 10),
labels = c("-", "0", "20", "40", "60", "80", "100"),
rotation = 108,
direction = "clockwise",
hole = 0.4,
textinfo = "label",
textposition = "outside",
hoverinfo = "none",
domain = list(x = c(0, 0.48), y = c(0, 1)),
marker = list(colors = c('rgb(255, 255, 255)', 'rgb(255, 255, 255)', 'rgb(255, 255, 255)', 'rgb(255, 255, 255)', 'rgb(255, 255, 255)', 'rgb(255, 255, 255)', 'rgb(255, 255, 255)')),
showlegend = FALSE
)
base_plot <- add_trace(
base_plot,
type = "pie",
values = c(50, 10, 10, 10, 10, 10),
labels = c("Error Log Level Meter", "Debug", "Info", "Warn", "Error", "Fatal"),
rotation = 90,
direction = "clockwise",
hole = 0.3,
textinfo = "label",
textposition = "inside",
hoverinfo = "none",
domain = list(x = c(0, 0.48), y = c(0, 1)),
marker = list(colors = c('rgb(255, 255, 255)', 'rgb(232,226,202)', 'rgb(226,210,172)', 'rgb(223,189,139)', 'rgb(223,162,103)', 'rgb(226,126,64)')),
showlegend= FALSE
)
a <- list(
showticklabels = FALSE,
autotick = FALSE,
showgrid = FALSE,
zeroline = FALSE)
b <- list(
xref = 'paper',
yref = 'paper',
x = 0.23,
y = 0.45,
showarrow = FALSE,
text = '50')
base_chart <- layout(
base_plot,
shapes = list(
list(
type = 'path',
path = path,
xref = 'paper',
yref = 'paper',
fillcolor = 'rgba(44, 160, 101, 0.5)'
)
),
xaxis = a,
yaxis = a,
annotations = b
)
为什么该路径不起作用?我希望这不是我无知地忽视的显而易见的答案.
Why won't this path work? I hope it isn't an obvious answer that I'm ignorantly overlooking.
推荐答案
path
字符串的定义中存在错误.
这是正确的sintax:
There is an error in the definition of the path
string.
Here is the right sintax:
path = paste('M 0.235 0.5 L' , x, y, 'L 0.245 0.5 Z')
这篇关于表盘位置规图P的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!