I'd like my graph to start at y=0
. Hence, all bars with a zero value should not be shown in the figure. However, bars with zero values are showing in my graph as if they had a negative value. See
.
This is the data series used in the graph:
data1$Node
[1] "EQU" "GYP" "NON" "NOZ" "BIG" "NZB" "ORS" "KAF"
data1$Flow
[1] "0.0e+00" "0.0e+00" "0.0e+00" "0.0e+00" "0.0e+00" "0.0e+00" "0.0e+00" "1.2e-05"
Something similar will happen if I set the ymin limit to 0: in this case bars don't appear but the 0 is not set at bottom
.
I've tried to solve the problem looking a previous questions but nothing seems to work. The code runs but it simply does not do what I'd like it to do. See code below:
cond1<-which(datagraph3$quality==targetQuality)
Flow<-datagraph3$budget[,cond1]
data1<-as.data.frame(Flow)
data1$Node<-rownames(data1)
data1$Flow<-formatC(data1$Flow, format = "e", digits = 1)
data1$Node<-c(data1$Node[2],data1$Node[3],data1$Node[5],data1$Node[6],
data1$Node[1],data1$Node[7],data1$Node[8],data1$Node[4])
ymin=min(data1$Flow)
ymax=max(data1$Flow)
barp1<-ggbarplot(data1, x="Node", y="Flow",
ylab=datagraph3$unit[cond1], xlab="Node",
color="white", fill="grey", palette="jco",
label=TRUE) + theme(plot.margin = margin(1,0.5,0.5,0.5, "cm"))
#+ scale_y_discrete(expand = c(ymin, ymax), limits = c(0, ymax), breaks = data1$Flow)
print(barp1+ylim(ymin,ymax)) # + font("x.text", size=7)