Column Chart with condition-based coloring in R and highcharts

dloudtrain

I want to produce a column chart with highcharts in R which would display the values larger than 0 in blue color and values less than 0 in red. Is there any straightforward way of doing this?

My chart code is simple as this:

hchart(
  df_temps, 
  "column",
  hcaes(x = Device, y = Temperature))

The data (df_temps) looks like this:

Device    Temperature
A         -0.78
B         14.8

Thank you very much for any suggestions.

pascal

For your example, this would work:

df_temps <- data.frame(Device = c("A","B"), Temperature = c(-0.78,14.8))
hchart(
  df_temps, 
  "column",
  hcaes(x = Device, y = Temperature, color=c("#910000","#2f7ed8")))

More generally and "condition-based":

df_temps <- data.frame(Device = c("A","B"), Temperature = c(-0.78,14.8))
df_temps$col <- ifelse(sign(df_temps$Temperature)==-1, "#910000","#2f7ed8")
    hchart(
      df_temps, 
      "column",
      hcaes(x = Device, y = Temperature, color=col))

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Highcharts - Add Point to chart with different color based on some condition dynamically

From Dev

Updating Highcharts column chart based on drop down-menu

From Dev

Highcharts column chart grouping

From Dev

R create new column based on if else condition

From Dev

Highcharts : Change opacity of a column chart

From Dev

Tooltip help in HighCharts Column chart

From Dev

Highcharts - column chart with drilldown to waterfall

From Dev

Drilldown for grouped column chart in highcharts

From Dev

Tooltip help in HighCharts Column chart

From Dev

Highcharts - column chart with drilldown to waterfall

From Dev

Coloring dendrogram’s end branches (or leaves) based on column number of data frame in R

From Dev

Highcharts converting a column chart to a pie chart

From Dev

Finding unique values in a column based on a condition in another column using r

From Dev

Coloring points based on variable with R ggpairs

From Dev

Column count based on a condition

From Dev

Add column based on condition

From Dev

Highcharts Redrawing images based off of chart width

From Dev

Highcharts bar chart with bar colored based on value

From Dev

Creating a new column of character values based on numeric value condition in R?

From Dev

How to select row based on condition in various column in R

From Dev

R, Shiny: subset a dataframe based on condition with reactive column name

From Dev

how can i add a column based on condition in R

From Dev

How to specific rows from a split list in R based on column condition

From Dev

filter dataframe based on condition on another column in the dataframe in R

From Dev

R - Mutating column value based on condition involving other columns' groups

From Dev

Highcharts tooltip bug with stacked column chart

From Dev

Color each point individually in column chart highcharts

From Dev

Highcharts: Remove padding around column chart

From Dev

Legend for each point in column chart in highcharts

Related Related

  1. 1

    Highcharts - Add Point to chart with different color based on some condition dynamically

  2. 2

    Updating Highcharts column chart based on drop down-menu

  3. 3

    Highcharts column chart grouping

  4. 4

    R create new column based on if else condition

  5. 5

    Highcharts : Change opacity of a column chart

  6. 6

    Tooltip help in HighCharts Column chart

  7. 7

    Highcharts - column chart with drilldown to waterfall

  8. 8

    Drilldown for grouped column chart in highcharts

  9. 9

    Tooltip help in HighCharts Column chart

  10. 10

    Highcharts - column chart with drilldown to waterfall

  11. 11

    Coloring dendrogram’s end branches (or leaves) based on column number of data frame in R

  12. 12

    Highcharts converting a column chart to a pie chart

  13. 13

    Finding unique values in a column based on a condition in another column using r

  14. 14

    Coloring points based on variable with R ggpairs

  15. 15

    Column count based on a condition

  16. 16

    Add column based on condition

  17. 17

    Highcharts Redrawing images based off of chart width

  18. 18

    Highcharts bar chart with bar colored based on value

  19. 19

    Creating a new column of character values based on numeric value condition in R?

  20. 20

    How to select row based on condition in various column in R

  21. 21

    R, Shiny: subset a dataframe based on condition with reactive column name

  22. 22

    how can i add a column based on condition in R

  23. 23

    How to specific rows from a split list in R based on column condition

  24. 24

    filter dataframe based on condition on another column in the dataframe in R

  25. 25

    R - Mutating column value based on condition involving other columns' groups

  26. 26

    Highcharts tooltip bug with stacked column chart

  27. 27

    Color each point individually in column chart highcharts

  28. 28

    Highcharts: Remove padding around column chart

  29. 29

    Legend for each point in column chart in highcharts

HotTag

Archive