折线图质量低 [英] low quality of line charts

查看:50
本文介绍了折线图质量低的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我所做的任何折线图都是前卫且质量低下的,当它是 png 格式时,我尝试了 pdf 并且非常流畅和漂亮.

any line chart that i do is edgy and has low quality when it's in png format i tried pdf and it was very smooth and nice.

我尝试过开罗套餐,但它只给了我黑色照片

i have tried Cairo package but it gave me only black photo

这是我原来的代码,质量很低

this is my code originally that gives low quality

plot(total_emmision_per_year[,1], (total_emmision_per_year[,2])/1000 , type = "b" , pch =19 , xlab = "Years" , ylab = "Emmision" , main = "Emissions across years")

dev.copy(png , file = "plot1_base_plot.png")
dev.off()

我试过:

library(Cairo)
Cairo(file="plot1_line.png", 
      type="png",
      units="in", 
      width=100, 
      height=100, 
      pointsize=12, 
      dpi=72)
dev.off()

我还尝试在 ggplot 上应用开罗包,但这里没有发生任何事情是代码:

edit : i also tried to apply Cairo package on ggplot and nothing happened here is the code :

line_colors <- c("steelblue","red","steelblue","steelblue")

ggplot(total_emission_from_coal_combustion , aes(years,emissions/100)) +
  geom_point(shape =19) +
  geom_line(size =1.1 , col =line_colors ) +
  ggtitle("total emission of coal combustion-related sources") +
  theme(plot.title = element_text(hjust = 0.5)) +
  ylab("emissions") +
  scale_x_discrete(limits = c(1999,2002,2005,2008))

library(Cairo)
Cairo(file="x.png", 
      type="png",
      units="in", 
      width=300, 
      height=300, 
      pointsize=12, 
      dpi=72)
dev.off()

推荐答案

我在 png 函数和 res 参数中使用 type = "cairo" 解决了这个问题也控制分辨率

i solved the problem using type = "cairo" within the png funcrion and the res argument also to control the resolution

 png(filename = "plot4.png",
 width =600, height = 600, units = "px", pointsize = 12,
 res = 130,type ="cairo")  

library(ggplot2)
ggplot(total_emission_from_coal_combustion , aes(years,emissions/100)) +
geom_point(shape =19) +
geom_line(size =1.1 , col =line_colors ) +
ggtitle("total emission of coal combustion-related sources") +
theme(plot.title = element_text(hjust = 0.5)) +
ylab("emissions") +
scale_x_discrete(limits = c(1999,2002,2005,2008))

dev.off() 

这篇关于折线图质量低的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆