Reputation: 89
Im constructing a bar chart, but the resolution is very poor, which is a problem as I want to use the chart for a research paper. Can anyone help me increase the resolution of the chart?
Im using the following code:
# Create the input vectors.
colors = c("black","grey")
years <- c("2013","2014","2015","2016","2017","2018","2019","2020","2021")
sectors <- c("Financials","Industrials")
# Give the chart file a name
png(file = "Panel B.png")
# Create the bar chart
barplot(PanelB, main = "Panel B. Numbers of corporate green bonds issued",
names.arg = years, xlab = "Years", ylab = "Number of green bonds issued", col = colors)
# Add the legend to the chart
legend("topleft", sectors, cex = 1.3, fill = colors)
# Save the file
dev.off()
Data:
PanelB <- structure(c(0, 0, 0, 0, 1, 16, 2, 12, 6, 14, 38, 29, 56, 31,
181, 59, 251, 58), .Dim = c(2L, 9L), .Dimnames = list(NULL, c("2013",
"2014", "2015", "2016", "2017", "2018", "2019", "2020", "2021"
)))
Upvotes: 0
Views: 293
Reputation: 2282
You can do this by using png("Panel B.png", width = 6, height = 4, units = 'in', res = 300)
More documentation on how to create higher resolution figures you will find here
PanelB <- structure(c(0, 0, 0, 0, 1, 16, 2, 12, 6, 14, 38, 29, 56, 31,
181, 59, 251, 58), .Dim = c(2L, 9L), .Dimnames = list(NULL, c("2013",
"2014", "2015", "2016", "2017", "2018", "2019", "2020", "2021"
)))
#Create the input vectors.
colors = c("black","grey")
years <- c("2013","2014","2015","2016","2017","2018","2019","2020","2021")
sectors <- c("Financials","Industrials")
#Give the chart file a name
png(file = "Panel B.png")
png("Panel B.png", width = 6, height = 4, units = 'in', res = 300)
#Create the bar chart
barplot(PanelB, main = "Panel B. Numbers of corporate green bonds issued",
names.arg = years, xlab = "Years", ylab = "Number of green bonds issued", col = colors)
#Add the legend to the chart
legend("topleft", sectors, cex = 1.3, fill = colors)
#Save the file
dev.off()
Old:
Upvotes: 1