Re: [R] How to customize legend labels in ggplot2?

2025-03-12 Thread Luigi Marongiu
Thank you, but then I will have long labels also on the axis, making the plot too crowded. I would like instead to force the long labels only on the legend... On Wed, 12 Mar 2025, 12:47 Rui Barradas, wrote: > Às 10:35 de 12/03/2025, Luigi Marongiu escreveu: > > I have a data frame with measureme

Re: [R] How to customize legend labels in ggplot2?

2025-03-12 Thread Rui Barradas
Às 10:35 de 12/03/2025, Luigi Marongiu escreveu: I have a data frame with measurements in different conditions. I set the conditions as a factor using a notation for ease of use. I now want to plot the data and assign meaningful labels to the factors. I am using ggplot2; for the x axis I would li

Re: [R] How to customize legend labels in ggplot2?

2025-03-12 Thread Thierry Onkelinx
Dear Luigi, ggplot2 will use the factor levels as default values for the legend labels. Setting the factor labels of your target values fixes your problem. Best regards, ir. Thierry Onkelinx Statisticus / Statistician Vlaamse Overheid / Government of Flanders INSTITUUT VOOR NATUUR- EN BOSONDE

[R] How to customize legend labels in ggplot2?

2025-03-12 Thread Luigi Marongiu
I have a data frame with measurements in different conditions. I set the conditions as a factor using a notation for ease of use. I now want to plot the data and assign meaningful labels to the factors. I am using ggplot2; for the x axis I would like to keep the factors but in the legend I would li