0

The axes of the R plot() function have by default the titles:

xlab = "Model Quanntiles"
ylab = "Empirical Quantiles"

I need to replace the texts with their translations for Brazilian Portuguese.

How can I do this?

My code just prints a QQ plot of a fevd (fitted extreme values distribution) object.

plot(fD31,type = "qq", main = "MLE", cex.main = 2)

I have tried to simply replace the xlab and ylab values but it did not work.

plot(fD31,type = "qq", main = "MLE", cex.main = 2, xlab = "Quantis do Modelo",
ylab = "Quantis Empíricos")

EDIT

My complete code:

D31 <- read.csv("file.csv") 
# Variable CYCLES, containing 10.000 different values from 27945900 to 28875760
flmD31 <- fevd(D31$CYCLES, method = "Lmoments")
plot(flmD31,type = "qq", main = "LM", cex.main=2)

The dput()

27947751L,...., 27947844L), method = "Lmoments", type = "GEV", period.basis = "year", 
    par.models = list(threshold = ~1, location = ~1, scale = ~1, 
        log.scale = FALSE, shape = ~1, term.names = list(threshold = character(0), 
            location = character(0), scale = character(0), shape = character(0))), 
    const.loc = TRUE, const.scale = TRUE, const.shape = TRUE, 
    n = 10000L, na.action = "na.fail", results = c(location = 27947289.4961838, 
    scale = 317.480635124479, shape = 0.740827367059249)), class = "fevd")
penelope
  • 15
  • 3
  • 1
    Could you share the output of `dput(fD31)` so that we can recreate the issue? Also, does Br-Pt mean Brazilian Portuguese? Its better to type it out as many readers may not know this – jpsmith Mar 15 '23 at 18:19
  • 2
    `plot` is a generic function. It behaves differently based on what packages you have loaded and the class of object you pass to it. It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input that can be used to test and verify possible solutions. – MrFlick Mar 15 '23 at 18:21
  • To add the data use [edit](https://stackoverflow.com/posts/75748606/edit) – zx8754 Mar 15 '23 at 18:47
  • The plot method for `fevd` objects does not have an `xlab` argument, so you probably need to change the variable name in the `fevd` object itself, either when you create it or afterwards. https://search.r-project.org/CRAN/refmans/extRemes/html/fevd.html – Jon Spring Mar 15 '23 at 18:53
  • Thanks everybody! I have editted the post with more details. – penelope Mar 15 '23 at 19:03
  • 1
    It's good practice to include `library(extRemes)` in your code if that is the package your `fevd` function comes from. – Jon Spring Mar 15 '23 at 19:16
  • 2
    It doesn't look like your dput output is complete. – Jon Spring Mar 15 '23 at 19:16
  • you can always do `plot(fD31, ann = FALSE)` then use `title(xlab = '', ylab = '', main = '')` – rawr Mar 15 '23 at 19:20

1 Answers1

0

If you want to properly fix this issue, you may need to define your own version of plot.fevd (and maybe quantquant.plot.evd and a few other internal functions) which seem to manually define the axis titles - meaning you can't override them in the normal way.

If you want a hacky solution, you could change the text colour of the current axis titles to white, and then add your own axis labels on top of them.

flmD31 <- fevd(mtcars$cyl, method = "Lmoments")
plot(flmD31,type = "qq",
     main = "LM",
     cex.main=2,
     col.lab = 'white')
title(xlab = "Quantis do Modelo",
      ylab = "Quantis Empíricos")

gives:

enter image description here

Note that this isn't a great solution, as the original axis titles are still there, and if you output to PDF format, will still be picked up by e.g. screenreaders so use with caution.

nrennie
  • 1,877
  • 1
  • 4
  • 14