繁体   English   中英

Plotly:平行坐标图:轴样式

[英]Plotly: Parallel Coordinates Plot: Axis Styling

我真的很喜欢Plotly中可用的平行坐标图,但我遇到了一个我可以使用帮助的问题。

对于某些坐标,是否可以使用基于log10的轴?

正如您在下面的示例中所看到的,执行log10转换可以更好地区分较小的值。 但是,通过转换数据,我们失去了解释值的能力。 我更愿意记录缩放轴而不是数据但是找不到这样做的方法。

我确实在github问题https://github.com/plotly/plotly.js/issues/1071#issuecomment-264860379中找到了与“轴样式”相关的内容,但没有找到解决此问题的方法。

我会很感激任何想法/指针。

情节

library(plotly)

# Setting up some data that span a wide range.
df <- read.csv("https://raw.githubusercontent.com/bcdunbar/datasets/master/iris.csv")
df$sepal_width[1] = 50
df$sepal_width_log10 = log10(df$sepal_width)

p <- df %>%
plot_ly(type = 'parcoords',
        line = list(color = ~species_id,
                    colorscale = list(c(0,'red'),c(0.5,'green'),c(1,'blue'))),
        dimensions = list(
            list(range = c(~min(sepal_width),~max(sepal_width)),
                label = 'Sepal Width', values = ~sepal_width),
            list(range = c(~min(sepal_width_log10),~max(sepal_width_log10)),
                tickformat='.2f',
                label = 'log10(Sepal Width)', values = ~sepal_width_log10),
            list(range = c(4,8),
                constraintrange = c(5,6),
                label = 'Sepal Length', values = ~sepal_length))
        )
p

更多平行坐标示例

Plotly Parallel Coordinates Doc

底层的plotly.js parcoords目前不支持日志投影(比例,轴),但正如你所提到的那样,它有时出现,我们计划使用此功能。 与此同时,一个选项是提前获取数据的对数,轴刻度将显示日志值的大缺点,这需要解释并增加认知负担。

由于不支持日志投影(但)手动创建刻度标签似乎是一种有效的解决方案。

# Lets create the axis text manually and map the log10 transform
# back to the original scale.
my_tickvals = seq(min(df$sepal_width_log10), max(df$sepal_width_log10), length.out=8)
my_ticktext = signif(10 ^ my_tickvals, digits = 2)

在此输入图像描述

library(plotly)

# Setting up some data that span a wide range.
df <- read.csv("https://raw.githubusercontent.com/bcdunbar/datasets/master/iris.csv")
df$sepal_width[1] = 50
df$sepal_width_log10 = log10(df$sepal_width)

# Lets create the axis text manually and map the log10 transform back to the original scale.
my_tickvals = seq(min(df$sepal_width_log10), max(df$sepal_width_log10), length.out=8)
my_ticktext = signif(10 ^ my_tickvals, digits = 2)

p <- df %>%
  plot_ly(type = 'parcoords',
          line = list(color = ~species_id,
                      colorscale = list(c(0,'red'),c(0.5,'green'),c(1,'blue'))),
          dimensions = list(
            list(range = c(~min(sepal_width),~max(sepal_width)),
                 label = 'Sepal Width', values = ~sepal_width),
            list(range = c(~min(sepal_width_log10),~max(sepal_width_log10)),
                 tickformat='.2f',
                 label = 'log10(Sepal Width)', values = ~sepal_width_log10),
            list(range = c(~min(sepal_width_log10),~max(sepal_width_log10)),
                 tickvals = my_tickvals,
                 ticktext = my_ticktext,
                 label = 'Sepal Width (log10 axis)', values = ~sepal_width_log10),
            list(range = c(4,8),
                 constraintrange = c(5,6),
                 label = 'Sepal Length', values = ~sepal_length))
          )
p

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM