Presentation of disproportionate rmarkdown graph

1

Hello, I have the following problem: when I print the chart in Rmarkdown it gets the numbers one above the others, besides the month / year indication in the coordinates also get the wrong view ..

Isthereanycodetoincreasethesizeofthegraphsothisdoesnothappen?Oranyideasforimprovement?

ggplot(data=planilha.grafico,aes(x=Ano,y=value,color=type))+geom_line(size=1.0)+scale_x_date(date_breaks="1 month", date_labels 
= "%b/%Y") + 
 labs(title = "Gráfico 8: Evolução do Reajuste de Inativos",
       subtitle = "Fonte: Base de Dados SIGRH", x = " ", y = "Quantidade") + 
  theme(axis.line.x = element_line(size = .5, colour = "black"),
        axis.line.y = element_line(size = .5, colour = "black"),
        axis.text.x = element_text(colour = "black", size = 8),
        axis.text.y = element_text(colour = "black", size = 8),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(), 
        panel.background = element_blank(),
        legend.position = "bottom", legend.direction = "horizontal",
        legend.title = element_blank()) + 
  geom_point(size=1.5) +scale_y_continuous(limits = c(0, 160000)) + 
  geom_text(data = planilha.grafico, aes(x=Ano, y=value, label = value, 
vjust = -1.1), size=3)

dput the data used to create the chart

## structure(list(Ano = structure(c(16801, 16832, 16861, 16892, 
## 16922, 16953, 16983, 17014, 17045, 17075, 17106, 17136, 17167, 
## 16801, 16832, 16861, 16892, 16922, 16953, 16983, 17014, 17045, 
## 17075, 17106, 17136, 17167), class = "Date"), type = c("Paridade", 
## "Paridade", "Paridade", "Paridade", "Paridade", "Paridade", "Paridade", 
## "Paridade", "Paridade", "Paridade", "Paridade", "Paridade", "Paridade", 
## "Média", "Média", "Média", "Média", "Média", "Média", "Média", 
## "Média", "Média", "Média", "Média", "Média", "Média"), value = c(149160, 
## 149300, 149599, 149787, 150039, 150319, 150507, 150584, 151025, 
## 151380, 151429, 151952, 151827, 4227, 4231, 4229, 4240, 4251, 
## 4258, 4377, 4404, 4427, 4471, 4502, 4554, 4581)), row.names = c(NA, 
## -26L), .Names = c("Ano", "type", "value"), class = c("tbl_df", 
## "tbl", "data.frame"))
    
asked by anonymous 18.08.2017 / 14:19

2 answers

2

You control this in the chunk parameters of RMarkdown:

'''{r fig.width = 7, fig.height = 7}
# código do seu gráfico
'''

7 is the height and width pattern, it will stir until you think it's fine. Here has a list of parameters that you can tweak in chunks. I pasted below the specifics of the graphs. If the width and height do not work you can try to move them too. Sometimes you have to fiddle with out.width and out.height too.

    
18.08.2017 / 14:37
1

I came up with the following chart:

Forthis,Ihavesetthefollowingparameters:

  • Ihaveincreasedtheaxislimitandusingtheme.IfIdidnotdothat,thedotlabelswouldnotfitinthefinalimage.

Thecompletecodelookslikethis:

ggplot(data=planilha.grafico,aes(x=Ano,y=value,color=type))+geom_line(size=1.0)+scale_x_date(date_breaks="1 month", date_labels = "%b/%Y") + 
  labs(title = "Gráfico 8: Evolução do Reajuste de Inativos",
       subtitle = "Fonte: Base de Dados SIGRH", x = " ", y = "Quantidade") + 
  theme(axis.line.x = element_line(size = .5, colour = "black"),
        axis.line.y = element_line(size = .5, colour = "black"),
        axis.text.x = element_text(angle = 90, colour = "black", size = 8),
        axis.text.y = element_text(colour = "black", size = 8),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(), 
        panel.background = element_blank(),
        legend.position = "bottom", legend.direction = "horizontal",
        legend.title = element_blank()) + 
  geom_point(size=1.5) + 
  scale_y_continuous(limits = c(0, 170000)) + 
  geom_text(data = planilha.grafico, aes(x=Ano, y=value, label = value, 
    hjust=0, vjust = -1.5), size=3, angle = 45)
    
18.08.2017 / 23:43