How can I colour specific data bars in R Histogram

David Dickson

If I have a histogram:

> hist(faithful$waiting,seq(min(faithful$waiting),max(faithful$waiting)))

and a list of "special" frequencies:

> c(51, 52, 57, 59, 64)

is it possible to colour the bars corresponding to these special frequencies a different colour from the rest of the histobram?

cdeterman

You could simply create a vector of the colors and use the col option.

data(faithful)

# make sure frequencies in order and unique for the histogram call
special <- ifelse(sort(unique(faithful$waiting)) %in% c(51, 52, 57, 59, 64), "red", "white")

# same call with the 'col' option
hist(faithful$waiting,seq(min(faithful$waiting),max(faithful$waiting)), col=special)

enter image description here

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I change the colour of specific bars in jFreeChart bar

From Dev

Change colour of specific histogram bins in R

From Dev

How to avoid gaps between bars of histogram in R?

From Dev

How to avoid gaps between bars of histogram in R?

From Dev

How can I create a histogram in R?

From Dev

How can I print an R macro in Markdown in colour?

From Dev

How can I reshape my data before I turn it into a histogram?

From Dev

R: How can I make a barplot with labels parallel (horizontal) to bars

From Dev

R - How do I generate a histogram of this data frame?

From Dev

R - How do I generate a histogram of this data frame?

From Dev

How to set certain values to specific colour in R?

From Dev

How can I look for a certain pixel colour on my screen, in a specific area using Python's PIL?

From Dev

How can I change the colour of a line that starts with specific characters in javascript/css?

From Dev

How can I look for a certain pixel colour on my screen, in a specific area using Python's PIL?

From Dev

How can I set the font colour?

From Dev

Changing the colour of the bars in a ggplot bar graph in R

From Dev

How to colour bars in a ggplot2 graph considering the order in a numeric variable of one data frame

From Dev

Display Chart (Histogram) Bars with real time data

From Dev

How to define fill colour for columnstacked histogram in gnuplot

From Dev

Remove borders from bars in histogram in R

From Dev

R - reordering histogram bars - ggplot2

From Dev

How can I visualize a histogram with Promdash or Grafana?

From Dev

how can I fix my histogram plot

From Dev

How can I use Excel data bars to format cells with text values?

From Dev

How can I get Windows 7 to display drives with bars indicating drive data usage?

From Dev

How can I segment data in R to include only points for which one of my variables is set to a specific value?

From Dev

R: How can I cbind specific columns of all data frames of a nested loop within the loop?

From Dev

How to apply histogram on dependent data in R?

From Dev

How to histogram one dimensional data in r?

Related Related

  1. 1

    How can I change the colour of specific bars in jFreeChart bar

  2. 2

    Change colour of specific histogram bins in R

  3. 3

    How to avoid gaps between bars of histogram in R?

  4. 4

    How to avoid gaps between bars of histogram in R?

  5. 5

    How can I create a histogram in R?

  6. 6

    How can I print an R macro in Markdown in colour?

  7. 7

    How can I reshape my data before I turn it into a histogram?

  8. 8

    R: How can I make a barplot with labels parallel (horizontal) to bars

  9. 9

    R - How do I generate a histogram of this data frame?

  10. 10

    R - How do I generate a histogram of this data frame?

  11. 11

    How to set certain values to specific colour in R?

  12. 12

    How can I look for a certain pixel colour on my screen, in a specific area using Python's PIL?

  13. 13

    How can I change the colour of a line that starts with specific characters in javascript/css?

  14. 14

    How can I look for a certain pixel colour on my screen, in a specific area using Python's PIL?

  15. 15

    How can I set the font colour?

  16. 16

    Changing the colour of the bars in a ggplot bar graph in R

  17. 17

    How to colour bars in a ggplot2 graph considering the order in a numeric variable of one data frame

  18. 18

    Display Chart (Histogram) Bars with real time data

  19. 19

    How to define fill colour for columnstacked histogram in gnuplot

  20. 20

    Remove borders from bars in histogram in R

  21. 21

    R - reordering histogram bars - ggplot2

  22. 22

    How can I visualize a histogram with Promdash or Grafana?

  23. 23

    how can I fix my histogram plot

  24. 24

    How can I use Excel data bars to format cells with text values?

  25. 25

    How can I get Windows 7 to display drives with bars indicating drive data usage?

  26. 26

    How can I segment data in R to include only points for which one of my variables is set to a specific value?

  27. 27

    R: How can I cbind specific columns of all data frames of a nested loop within the loop?

  28. 28

    How to apply histogram on dependent data in R?

  29. 29

    How to histogram one dimensional data in r?

HotTag

Archive