Skip to content

Plot legend size too small for text to fit #216

@hugotomasf

Description

@hugotomasf

When the plot is generated as an image in RStudio, the legend text fits perfectly but when exported to TikZ the legend size is too
small to fit. Here is the plot generated by R:
Rplot1
This is the TikZ image generated in a latex document:
Screenshot from 2022-06-17 18-46-49
Changing the width of the export does not fix the problem:
Screenshot from 2022-06-17 18-46-00

Here is the R code:

library(tikzDevice)

set.seed(10) 
tikz('prueba.tex', width = 3, height = 3)

colores = c("blue", "red", "green", "purple", "orange")

x = runif(5, min = 10, max = 17)
y = 3000*x + 30000
plot(x, y, 
     xlab = "Educación (Años)",
     pch = 20,
     col = colores, 
     ylab = "Renta (€)",
     xlim=c(10, 17),
     ylim=c(3000*10 + 30000,3000*17 + 30000),
     bty = "L")

legend(x = "bottomright",
       legend = c("Ciudad 1", "Ciudad 2", "Ciudad 3", "Ciudad 4", "Ciudad 5"),
       pch = c(20,20,20,20,20),
       col = colores)

dev.off()

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions