[R] Lines in a line graph not visible when values are identical

Jan van der Laan rhe|p @end|ng |rom eoo@@dd@@n|
Tue Oct 13 12:24:17 CEST 2026


What also sometimes can work is making the lines semi-transparent using 
geom_line(alpha = 0.5), for example.

HTH,
Jan



On 12-10-2026 10:58, Bob Green via R-help wrote:
> Thanks. I opted to change the linestyle,  lty in Base R or linetype in 
> ggplot2. It worked fine.
> 
> 
> 
> At 06:44 PM 10/10/2026, CALUM POLWART wrote:
>> I'm not entirely sure I've understood the issue, but is this exactly 
>> what jitter exists for
>>
>>
>> geom_line(position=position_jitter(w=0.1) ...
>>
>> Adding some slight "bounce" to the plotted likes to make them not 
>> overlap.Â
>>
>> Jitter always worries me slightly that you are lying slightly with the 
>> data although the idea is it is supposed to be by a neglible amount.
>>
>> Or, using a dotted line over a solid line can fix this ?
>>
>> In essence if you have
>>
>> ---------Â
>>
>> Currently with both lines under eachother making one of them dotted 
>> means you get
>>
>> --•---•---•-
>>
>> The [poor] colour vision world might suggest that's better anyway!
>>
>> Or I may have misunderstood the problem!
>>
>> On Thu, 8 Oct 2026, 22:03 Bob Green via R-help, <<mailto:r-help using r- 
>> project.org>r-help using r-project.org> wrote:
>> Thanks Rui,
>>
>> Much appreciated. Regarding why I spelt out
>> millimetres, I seldom use them as a measurement
>> so it was mostly for that reason and because the
>> data was in an Excel spreadsheet.
>>
>> To get a more direct comparison, I create a panel
>> of four bargraphs, one for each parameter by year.
>>
>> Regards
>>
>> Bob
>>
>>   At 01:27 AM 10/9/2026, Rui Barradas wrote:
>> >Hello,
>> >
>> >What if instead of colors, you facet the plot by Year?
>> >
>> >
>> >ggplot(DF, aes(x = Parameter, y = Millimetres, group = Year)) +
>> >   geom_line(linewidth = 1) +
>> >   geom_point(size = 2) +
>> >   labs(
>> >     title = "Parameters by Year",
>> >     x = "Parameter",
>> >     y = "Millimetres ($)"
>> >   ) +
>> >   facet_wrap(~ Year) +
>> >   theme_minimal()
>> >
>> >
>> >Also, the data in dput format.
>> >
>> >DF <-
>> >structure(list(Parameter = structure(c(1L, 2L, 3L, 4L, 1L, 2L,
>> >3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L,
>> >3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L), levels = c("Tail", "Tail_b",
>> >"Nose_b", "Nose"), class = "factor"), Millimetres = c(0, 0, 20.3,
>> >74.9, 0, 0, 14, 63.7, 11.2, 2.8, 16.3, 72.6, 0, 0, 17.1, 72.5,
>> >11.3, 2.9, 16.9, 74.7, 28.1, 4.9, 6.8, 37.7, 25.9, 5.2, 11.2,
>> >68.1, 30.2, 6.35, 15.1, 76.2), Year = c("2010-2012", "2010-2012",
>> >"2010-2012", "2010-2012", "2014", "2014", "2014", "2014", "2016",
>> >"2016", "2016", "2016", "2023", "2023", "2023", "2023", "2024",
>> >"2024", "2024", "2024", "2025C", "2025C", "2025C", "2025C", "2025B",
>> >"2025B", "2025B", "2025B", "2026", "2026",
>> >"2026", "2026")), row.names = c("1",
>> >"2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13",
>> >"14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24",
>> >"25", "26", "27", "28", "29", "30", "31", "32"), class = "data.frame")
>> >
>> >Bob Green via R-help <<mailto:r-help using r-project.org>r-help using r- 
>> project.org> escreveu (quinta,
>> >8/10/2026 Ã (s) 11:19):
>> > >
>> > > Hello,
>> > >
>> > > I'm pretty rusty using R but wanted to compare
>> > > four parameters measured in mm, in terms of the year an object was 
>> created.
>> > >
>> > > My problem is that where there are identical
>> > > values, only one line is produced. For example,
>> > > for the first parameter "tail",only five of a
>> > possible eight lines are visible.
>> > >
>> > > The code and full dataset are below. I considered
>> > > making trivial differences to identical values of
>> > > a parameter to create difference,but no doubt
>> > > there are more elegant or sophisticated options.
>> > >
>> > > Any advice is appreciated,
>> > >
>> > > Bob
>> > >
>> > > library(ggplot2)
>> > > library(tidyr)
>> > > library(readxl)
>> > > DF <- read_excel("C:/Files/DataLong.xlsx")
>> > > DF
>> > >
>> > >
>> > > DF$Parameter <- factor(DF$Parameter, levels =
>> > > c("Tail", "Tail_b", "Noseb", "Nose"))
>> > >
>> > >
>> > > ggplot(DF, aes(x = Parameter, y =
>> > Millimetres, color = Year, group = Year)) +
>> > >    geom_line(linewidth = 1) +
>> > >    geom_point(size = 2) + labs(title =
>> > > "Parameters by Year", x = "Parameter", y = "Millimetres ($)") +
>> > >    theme_minimal()
>> > >
>> > > ##Data
>> > >
>> > >
>> > > # A tibble: 32 × 3
>> > >     Parameter Millimetres Year
>> > >     <fct>           <dbl> <chr>
>> > >   1 Tail             0    2010-2012
>> > >   2 Tail_b           0    2010-2012
>> > >   3 Nose_b          20.3  2010-2012
>> > >   4 Nose            74.9  2010-2012
>> > >   5 Tail             0    2014
>> > >   6 Tail_b           0    2014
>> > >   7 Nose_b          14    2014
>> > >   8 Nose            63.7  2014
>> > >   9 Tail            11.2  2016
>> > > 10 Tail_b           2.8  2016
>> > > 11 Nose_b          16.3  2016
>> > > 12 Nose            72.6  2016
>> > > 13 Tail             0    2023
>> > > 14 Tail_b           0    2023
>> > > 15 Nose_b          17.1  2023
>> > > 16 Nose            72.5  2023
>> > > 17 Tail            11.3  2024
>> > > 18 Tail_b           2.9  2024
>> > > 19 Nose_b          16.9  2024
>> > > 20 Nose            74.7  2024
>> > > 21 Tail            28.1  2025C
>> > > 22 Tail_b           4.9  2025C
>> > > 23 Nose_b           6.8  2025C
>> > > 24 Nose            37.7  2025C
>> > > 25 Tail            25.9  2025B
>> > > 26 Tail_b           5.2  2025B
>> > > 27 Nose_b          11.2  2025B
>> > > 28 Nose            68.1  2025B
>> > > 29 Tail            30.2  2026
>> > > 30 Tail_b           6.35 2026
>> > > 31 Nose_b          15.1  2026
>> > > 32 Nose            76.2  2026
>> > >
>> > > ______________________________________________
>> > > <mailto:R-help using r-project.org>R-help using r-project.or g mailing list -- 
>> To UNSUBSCRIBE and more, see
>> > > <https://stat.ethz.ch/mailman/listinfo/r-help>https:// 
>> stat.ethz.ch/mailman/listinfo/r-help
>> > > PLEASE do read the posting guide
>> > <https://www.R-project.org/posting-guide.html>https://www.R- 
>> project.org/posting-guide.html
>> > > and provide commented, minimal, self-contained, reproducible code.
>>
>> ______________________________________________
>> <mailto:R-help using r-project.org>R-help using r-project.org mailing list -- To 
>> UNSUBSCRIBE and more, see
>> <https://stat.ethz.ch/mailman/listinfo/r-help>https://stat.ethz.ch/ 
>> mailman/listinfo/r-help
>> PLEASE do read the posting guide <https://www.R-project.org/posting- 
>> guide.html>https://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
> 
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide https://www.R-project.org/posting- 
> guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list