[R] plotly

Kimmo Elo k|mmo@e|o @end|ng |rom utu@||
Wed Jul 26 09:33:25 CEST 2023


Hi,

ke, 2023-07-26 kello 02:04 +0000, Thomas Subia via R-help kirjoitti:
> Question 1:How can I save the plotly graph with a specific graph
> size?Using ggsave, one can define the height, width and unit of
> measure, is there something similar in plotly?Since I am creating the
> same gauge plot but with different data, I'd like all the resulting
> graphs to have the same size. I've googled this but to no avail,

Maybe this: plotly_IMAGE

See ?plotly_IMAGE for details, especially 'height' and 'width' should
be of interest for you.

> Question 2:How can I adjust the tick marks of the gauge? Ideally the
> tick marks should be set at seq(0,9600,1200)

Try this (notice 'tickvals' in gauge/axis:

--- snip ---

plot_ly(
    domain = list(x = c(0, .5), y = c(0,0.5)),
    value = 319,
    title = list(text = "Example\n4,800 Target",font=t),
    type = "indicator",
    mode = "gauge+number+delta",
    number = list(valueformat = "%.2f",font=t5), 
    delta = list(reference = 4800, valueformat = "%.2f",font=t3),
    gauge = list(
        axis = list(range = list(NULL, 9600), 
                    tickformat = "%d",
                    tickvals = seq(0,9600,1200),
                    tickfont = list(size = 12, face="bold",family =
"Arial")),
        bar = list(color = "black"),
        steps = list(
            list(range = seq(0, 4800,1200), color = 'AAFF00'),
            list(range = seq(4800, 9600,1200), color = 'ffb2b2')),
        threshold = list(
            line = list(color = "black", width = 8),
            thickness = 0.75,
            value = 4800)))

--- snip ---

HTH,

Kimmo



More information about the R-help mailing list