I am trying to draw a plot in R using barplot()
. But I am running into a few problems. First I am attaching an image of the plot and the code I am using to plot this. Then I am describing the problems.
The Image:
Here is the code snippet that I am using to generate this plot.
par(mar=c(14, 7, 2, 2), mgp=c(5,2,0))
midpts<-barplot(x[,input$year],
main=input$year,
ylab="Number of Units",
xlab="Product",col='maroon')
vps <- baseViewports()
pushViewport(vps$inner, vps$figure, vps$plot)
grid.text(rownames(x),
x = unit(midpts, "native"), y=unit(-1, "lines"),
just="right", rot=90)
popViewport(3)
The problems:
1) This whole plot also looks very small overall and I would like this to be larger.
2) Some markers in the Y axis are not visible. The missing markers depend on the "Year" dropdown. For some years, all the Y axis markers will appear, for others, a couple will be missing like for this one.
3) Can someone also tell me how can I make my X label ("Product") and Y label ("Number of Units") bold and distinct so that they can be differentiated from the markers?
Note: This plot is part of a R-Shiny dashboard, but I don't think that this is relevant for making the changes.