The problem with the logarithmic scale on the Ggplot chart

I am trying to create a grouped graph with a logarithmic scale using ggplot2 in R. My goal was to recreate the next graph in R.

enter image description here

Since the created program cannot create high-resolution graphics. I need a magazine scale because the numbers range from 1 to over 1000, and everywhere in between.

This is a snippet of a simplified version of the data framework, as well as the code I used. I was able to make the plot using ggplot2, but my problem is that I have a lot of data in 1, which ultimately displays as 0s and 0s, which display as -1. This is what my R-chart looks like.

genus_counts <- read.table(text = "Genus variable value
1  Lepisosteus  JBGC462     0
2      Lepomis  JBGC462     6
3  Micropterus  JBGC462     2
4        Perca  JBGC462     2
5    Ictalurus  JBGC462     1
6  Lepisosteus   JBGC13    13
7      Lepomis   JBGC13     0
8  Micropterus   JBGC13     0
9        Perca   JBGC13     0
10   Ictalurus   JBGC13     0", header = TRUE)


ggplot(genus_counts, aes(x=Genus, y=value, fill=variable))+
      geom_bar(stat="identity", position="dodge")+
      scale_y_log10()

enter image description here

, ( , ). ( , ), , ?

+4
2

, scale_y_sqrt(), . 1000, , , 1, 2, .

enter image description here

+3

, , , , 0 .

, , y:

genus_counts <- read.table(text = "Genus variable value
1  Lepisosteus  JBGC462     0
2      Lepomis  JBGC462     6
3  Micropterus  JBGC462     2
4        Perca  JBGC462     2
5    Ictalurus  JBGC462     1
6  Lepisosteus   JBGC13    13
7      Lepomis   JBGC13     0
8  Micropterus   JBGC13     0
9        Perca   JBGC13     0
10   Ictalurus   JBGC13     0", header = TRUE)


ggplot(genus_counts, aes(x=Genus, y=value, fill=variable))+
  geom_bar(stat="identity", position="dodge")+
  scale_y_log10(limits = c(0.1, 15))

enter image description here

. , :

ggplot(genus_counts, aes(x=Genus, y=value, fill=variable))+
  geom_bar(stat="identity", position="dodge")+
  scale_y_log10(limits = c(1e-100, 15))

enter image description here

, 1, 1, < 1 , . ggplot2 . 0, , .

, , , , 0, 1 y. 0 , .

, - . :

ggplot(genus_counts, aes(x=Genus, y=value, fill=variable))+
  geom_bar(stat="identity", position="dodge")+
  scale_y_sqrt(limits = c(0, 15), breaks = (0:4)^2)

enter image description here

, . , , 6, 2,5 , , 1. , y .

+3

Source: https://habr.com/ru/post/1691205/


All Articles