-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjump_cars.qmd
737 lines (591 loc) · 22.5 KB
/
jump_cars.qmd
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
---
title: "Plotting cars"
webr:
packages: ['tidyverse']
editor:
mode: source
---
## Learn and code
First, let's make a simple scatter plot. We'll use a famous dataset that is used in R a lot for educational purposes. This is the `mtcars` dataset. It stands for _"Motor Trend Car Road Tests"_. See [parameter overview](https://rstudio-pubs-static.s3.amazonaws.com/61800_faea93548c6b49cc91cd0c5ef5059894.html){target="_blank"} and [documentation](https://www.rdocumentation.org/packages/datasets/versions/3.6.2/topics/mtcars){target="_blank"} for info about the `mtcars` dataset. It is one of many datasets available from base R or tidyverse packages, so we can always call it without having to load it.
First, we will inspect the dataset. For this we will load the tidyverse:
``` {webr-r}
library(tidyverse)
```
Once tidyverse is loaded via the `library` call, it is available in your current session in your browser, so you do not have to load it each time. Let's have a look at the full dataset:
``` {webr-r}
mtcars
```
or
``` {webr-r}
#if you get an error here,
# please load the library call to tidyverse
mtcars %>% glimpse()
```
or
``` {webr-r}
mtcars %>% head()
```
or
``` {webr-r}
mtcars %>% tail()
```
Let's select a small part of the data using `select` from the `dplyr` package:
``` {webr-r}
mtcars %>%
select(mpg, disp)
```
Next, make a simple plot with the miles per gallon (`mpg`) and displacement parameters (`disp`) in the `mtcars` dataset.
``` {webr-r}
mtcars %>%
select(mpg, disp) %>%
ggplot(aes(x = mpg, y = disp))+
geom_point(size = 4)
```
This is a very basic plot, without much formatting. Let's make it prettier!
Add color and bring in a third parameter:
``` {webr-r}
mtcars %>%
#added cyl to the selection here
select(mpg, disp, cyl) %>%
ggplot(aes(x = mpg,
y = disp,
color = cyl) #added color to the aesthetics here
) +
geom_point(size = 4)
```
Here we need to have a look at data-types. The `cyl` parameter is numerical. `ggplot` automatically assumes we want a continuous scale for this. Instead the `cyl` is more of a categorical data type (there are either 4, 6 or 8 cylinders in each car) so we can explicitly make the `cyl` parameter categorical like this:
``` {webr-r}
mtcars %>%
select(mpg, cyl, disp) %>%
ggplot(aes(x = mpg, y = disp,
color = as.factor(cyl))) +
geom_point(size = 4)
```
If you want to have different colors you can use one of the many color palettes available:
``` {webr-r}
mtcars %>%
select(mpg, cyl, disp) %>%
ggplot(aes(x = mpg, y = disp,
color = as.factor(cyl)))+
geom_point(size = 4)+
#I also manually changed the name of the legend here
scale_color_brewer(name = "cylinders",
palette = "Set2")
```
Apart from color you can change the shape of the datapoints:
``` {webr-r}
mtcars %>%
select(mpg, cyl, disp) %>%
ggplot(aes(x = mpg, y = disp,
color = as.factor(cyl),
#please note to also add shape to the aesthetics here
shape = as.factor(cyl))) +
geom_point(size = 4)+
scale_color_brewer(name = "cylinders",
palette = "Set2")+
scale_shape(solid = TRUE,
name = "cylinders")
```
`ggplot` can use different themes for your plots, and there are many many options to tweak your plots to the way you like. You can see some examples below:
Let's change titles:
``` {webr-r}
mtcars %>%
select(mpg, cyl, disp) %>%
ggplot(aes(x = mpg, y = disp,
color = as.factor(cyl),
shape = as.factor(cyl)))+
geom_point(size = 4)+
scale_color_brewer(name = "cylinders",
palette = "Set2")+
scale_shape(solid = TRUE,
name = "cylinders")+
labs(title = "My cool MTCARS plot",
x = "miles per gallon",
y = "dispension")
```
Change the plotting theme and base size of the elements:
``` {webr-r}
mtcars %>%
select(mpg, cyl, disp) %>%
ggplot(aes(x = mpg, y = disp,
color = as.factor(cyl),
shape = as.factor(cyl)))+
geom_point(size = 4)+
scale_color_brewer(name = "cylinders",
palette = "Set2")+
scale_shape(solid = TRUE,
name = "cylinders")+
labs(title = "My cool MTCARS plot",
x = "miles per gallon",
y = "dispension")+
theme_bw(base_size = 20)
```
Change the scaling of the axes. It is good practice to plot graphs from zero:
``` {webr-r}
mtcars %>%
select(mpg, cyl, disp) %>%
ggplot(aes(x = mpg, y = disp,
color = as.factor(cyl),
shape = as.factor(cyl)))+
geom_point(size = 4)+
scale_color_brewer(name = "cylinders",
palette = "Set2")+
scale_shape(solid = TRUE,
name = "cylinders")+
labs(title = "My cool MTCARS plot",
x = "miles per gallon",
y = "dispension")+
scale_x_continuous(limits = c(0, NA),
expand = c(0,NA))+
scale_y_continuous(limits = c(0, NA),
expand = c(0,NA))+
theme_bw(base_size = 20)
```
Now the datapoints at the maxima of the axis are not completely visible so it would be nice that we have some more space:
``` {webr-r}
mtcars %>%
select(mpg, cyl, disp) %>%
ggplot(aes(x = mpg, y = disp,
color = as.factor(cyl),
shape = as.factor(cyl)))+
geom_point(size = 4)+
scale_color_brewer(name = "cylinders",
palette = "Set2")+
scale_shape(solid = TRUE,
name = "cylinders")+
labs(title = "My cool MTCARS plot",
x = "miles per gallon",
y = "dispension")+
scale_x_continuous(
limits = c(0, NA),
expand = expansion(mult = c(0, 0.1)))+
scale_y_continuous(
limits = c(0, NA),
expand = expansion(mult = c(0, 0.1)))+
theme_bw(base_size = 20)
```
Now we have generated a nice visualisation of our data using `ggplot`. Please note that `ggplot` uses layers and we added each time a different layer of information to the ggplot. If you want you can go wild with `ggplot.` Please find a nice [overview](https://www.cedricscherer.com/2019/12/30/best-tidytuesday-2019/){target="_blank"} of visualisations using ggplot, tidy and R from Cedric Scherer. Also the underlying R code is available for those plots.
## Exercises
### Adding layers and changing the MTCARS plot
::: callout-tip
#### Exercise 1
Give the points in the ggplot some transparency (or opacity), so that individual points are better visible. TIP: use the `alpha` argument it should be a number from 0 to 1.
``` {webr-r}
mtcars %>%
select(mpg, cyl, disp) %>%
ggplot(aes(x = mpg, y = disp,
color = as.factor(cyl),
shape = as.factor(cyl)))+
geom_point(size = 4,
#type your extra code here:
)+
scale_color_brewer(name = "cylinders",
palette = "Set2")+
scale_shape(solid = TRUE,
name = "cylinders")+
labs(title = "My cool MTCARS plot",
x = "miles per gallon",
y = "dispension")+
scale_x_continuous(
limits = c(0, NA),
expand = expansion(mult = c(0, 0.1)))+
scale_y_continuous(
limits = c(0, NA),
expand = expansion(mult = c(0, 0.1)))+
theme_bw(base_size = 20)
```
:::
::: {.callout-caution collapse="true"}
#### Solution to Exercise 1
Please note that the alpha we added is not part of an aesthetics (`aes`), meaning that the value of the alpha is not linked with a parameter in our data.
``` {webr-r}
mtcars %>%
select(mpg, cyl, disp) %>%
ggplot(aes(x = mpg, y = disp,
color = as.factor(cyl),
shape = as.factor(cyl)))+
geom_point(size = 4,
#type your extra code here:
alpha = 0.7
)+
scale_color_brewer(name = "cylinders",
palette = "Set2")+
scale_shape(solid = TRUE,
name = "cylinders")+
labs(title = "My cool MTCARS plot",
x = "miles per gallon",
y = "dispension")+
scale_x_continuous(
limits = c(0, NA),
expand = expansion(mult = c(0, 0.1)))+
scale_y_continuous(
limits = c(0, NA),
expand = expansion(mult = c(0, 0.1)))+
theme_bw(base_size = 20)
```
:::
::: callout-tip
#### Exercise 2
Add a layer that will generate a smooth linear regression line that shows the relation between `mpg` and `disp`. Use the `stat_smooth` command for this.
``` {webr-r}
mtcars %>%
select(mpg, cyl, disp) %>%
ggplot(aes(x = mpg, y = disp))+
geom_point(size = 4,
alpha = 0.7)+
# enter code here
labs(title = "My cool MTCARS plot",
x = "miles per gallon",
y = "dispension")+
scale_x_continuous(
limits = c(0, NA),
expand = expansion(mult = c(0, 0.1)))+
scale_y_continuous(
limits = c(0, NA),
expand = expansion(mult = c(0, 0.1)))+
theme_bw(base_size = 20)
```
:::
::: {.callout-caution collapse="true"}
#### Solution to Exercise 2
Please make sure that the ggplot is not separated into groups. If the data is grouped by `color` or `shape` a different regression line for each group will be generated.
``` {webr-r}
mtcars %>%
select(mpg, cyl, disp) %>%
ggplot(aes(x = mpg, y = disp))+
geom_point(size = 4,
alpha = 0.7)+
# enter code here
stat_smooth(geom = "line",
method = "lm",
formula = "y ~ x")+
labs(title = "My cool MTCARS plot",
x = "miles per gallon",
y = "dispension")+
scale_x_continuous(
limits = c(0, NA),
expand = expansion(mult = c(0, 0.1)))+
scale_y_continuous(
limits = c(0, NA),
expand = expansion(mult = c(0, 0.1)))+
theme_bw(base_size = 20)
```
:::
::: callout-tip
#### Exercise 3
Use the `facet_wrap` command to make three separate plots for each cylinder.
``` {webr-r}
mtcars %>%
select(mpg, cyl, disp) %>%
ggplot(aes(x = mpg, y = disp))+
geom_point(size = 4,
alpha = 0.7)+
labs(title = "My cool MTCARS plot",
x = "miles per gallon",
y = "dispension")+
scale_x_continuous(
limits = c(0, NA),
expand = expansion(mult = c(0, 0.1)))+
scale_y_continuous(
limits = c(0, NA),
expand = expansion(mult = c(0, 0.1)))+
theme_bw(base_size = 20)
# enter code here
#(and don't forget to at a plus to the last line)
```
:::
::: {.callout-caution collapse="true"}
#### Solution to Exercise 3
``` {webr-r}
mtcars %>%
select(mpg, cyl, disp) %>%
ggplot(aes(x = mpg, y = disp))+
geom_point(size = 4,
alpha = 0.7)+
labs(title = "My cool MTCARS plot",
x = "miles per gallon",
y = "dispension")+
scale_x_continuous(
limits = c(0, NA),
expand = expansion(mult = c(0, 0.1)))+
scale_y_continuous(
limits = c(0, NA),
expand = expansion(mult = c(0, 0.1)))+
theme_bw(base_size = 20)+
facet_wrap(~cyl)
```
:::
### Fixing common errors
Below is some code that is not working properly, because of coding semantics mistakes. Can you spot (and fix) the errors?
::: callout-important
#### Fix error 1
``` {webr-r}
mtcars %>%
select(mpg, cyl, disp) %>%
ggplot(aes(x = mpg, y = disp
color = cyl))+
geom_point(size = 4)
```
:::
::: {.callout-caution collapse="true"}
#### Solution to Error 1
``` {webr-r}
mtcars %>%
select(mpg, cyl, disp) %>%
ggplot(aes(x = mpg, y = disp, #the error was here
color = cyl))+
geom_point(size = 4)
```
Commas are often forgotten, but easily fixed. Within brackets arguments are separated with commas. R also generates an error that is helpful and can point you to the missing `,`.
:::
::: callout-important
#### Fix error 2
``` {webr-r}
mtcars %>%
select(mpg, cyl, disp) %>%
ggplot(aes(x = mpg, y = disp,
color = cyl)) %>%
geom_point(size = 4)
```
:::
::: {.callout-caution collapse="true"}
#### Solution to Error 2
``` {webr-r}
mtcars %>%
select(mpg, cyl, disp) %>%
ggplot(aes(x = mpg, y = disp,
color = cyl))+ #the error was in this line
geom_point(size = 4)
```
`ggplot` layers are added with a `+` not with the `pipe` term.
:::
::: callout-important
#### Fix error 3
``` {webr-r}
mtcars %>%
select(mpg, cyl, disp) %>%
ggplot(aes(x = mpg, y = disp
color = cyl)) +
geom_point(size = 4) +
```
:::
::: {.callout-caution collapse="true"}
#### Solution to Error 3
``` {webr-r}
mtcars %>%
select(mpg, cyl, disp) %>%
ggplot(aes(x = mpg, y = disp,
color = cyl))+
geom_point(size = 4) #the error was in this line
```
Make sure that the end of a layer or line of code is not followed up with a `+` or `%>%`.
:::
::: callout-important
#### Fix error 4
Although R doesn't show you an error message, the code does not give you what you want. The plot should show the `cyl` parameter in different shapes, just like there are three different colors for each level of the `cyl` parameter.
``` {webr-r}
mtcars %>%
select(mpg, cyl, disp) %>%
ggplot(aes(x = mpg, y = disp,
color = as.factor(cyl)),
shape = as.factor(cyl))+
geom_point(size = 4)+
scale_color_brewer(name = "cylinders",
palette = "Set2")+
scale_shape(solid = TRUE,
name = "cylinders")
```
:::
::: {.callout-caution collapse="true"}
#### Solution to Error 4
``` {webr-r}
mtcars %>%
select(mpg, cyl, disp) %>%
ggplot(aes(x = mpg, y = disp,
color = as.factor(cyl), #parenthesis error
shape = as.factor(cyl)))+
geom_point(size = 4)+
scale_color_brewer(name = "cylinders",
palette = "Set2")+
scale_shape(solid = TRUE,
name = "cylinders")
```
The `shape` argument should be included in the aesthetics (`aes`) part of the ggplot
:::
::: {.callout-note collapse="true"}
#### Solution to Error 4 using chatGPT
Since chatGPT can also solve basic programming problems <https://doi.org/10.1371/journal.pcbi.1011511>, I tried solving Error 4 also with chatGPT. In my chatGPT session, the following solution was given:
``` {webr-r}
mtcars %>%
select(mpg, cyl, disp) %>%
ggplot(aes(x = mpg, y = disp,
color = as.factor(cyl),
shape = as.factor(cyl))) +
geom_point(size = 4) +
scale_color_brewer(name = "Cylinders", palette = "Set2") +
scale_shape_manual(
name = "Cylinders",
values = c(1, 2, 3), # Customize shape values as needed
labels = c("4", "6", "8")
)
```
chatGPT indeed put the `shape` in the `aes`, but also started making other changes. The remark that chatGPT made was: *"you should correct the syntax error and use scale_shape_manual() instead of scale_shape()."*... *"to customize the shape values and labels."*. I didn't really ask for that, and from there it went all downhill. Let's call that the "chatGPT loop of death". Let's see what happened.
Running the "improved" code showed that there was still no `fill`, so it did not improve in a way that I wanted.
Next I said *"but now the shapes don't have a fill"* and chatGPT replied:
*"I see your concern. If you want to have both color and fill for the shapes, you can achieve this by mapping fill within the aes() call and using scale_fill_brewer() for the fill scale. Here's the modified code to achieve that:"*
``` {webr-r}
mtcars %>%
select(mpg, cyl, disp) %>%
ggplot(aes(x = mpg, y = disp,
color = as.factor(cyl),
shape = as.factor(cyl),
fill = as.factor(cyl))) +
geom_point(size = 4) +
scale_color_brewer(name = "Cylinders", palette = "Set2") +
scale_fill_brewer(name = "Cylinders", palette = "Set2") +
scale_shape_manual(
name = "Cylinders",
values = c(1, 2, 3), # Customize shape values as needed
labels = c("4", "6", "8")
)
```
This again did not give fill unfortunately. Asking for a different solution: *"the fill is not there, do you have another solution?"*
``` {webr-r}
mtcars %>%
select(mpg, cyl, disp) %>%
ggplot(aes(x = mpg, y = disp,
color = as.factor(cyl),
shape = as.factor(cyl))) +
geom_point(size = 4) +
scale_color_brewer(name = "Cylinders", palette = "Set2") +
scale_fill_manual(
name = "Cylinders",
values = c("4" = "red", "6" = "blue", "8" = "green")
) +
scale_shape_manual(
name = "Cylinders",
values = c(1, 2, 3), # Customize shape values as needed
labels = c("4", "6", "8")
)
```
Also did not give me fill.
Another attempt by chatGPT (still not working):
``` {webr-r}
mtcars %>%
select(mpg, cyl, disp) %>%
mutate(cyl_shape_fill = as.factor(cyl)) %>%
ggplot(aes(x = mpg, y = disp,
shape = cyl_shape_fill,
color = cyl_shape_fill)) +
geom_point(size = 4) +
scale_shape_manual(
name = "Cylinders",
values = c("4" = 21, "6" = 22, "8" = 23),
labels = c("4", "6", "8")
) +
scale_color_manual(
name = "Cylinders",
values = c("4" = "red", "6" = "blue", "8" = "green")
)
```
Another attempt by chatGPT (still not working):
``` {webr-r}
mtcars %>%
select(mpg, cyl, disp) %>%
ggplot(aes(x = mpg, y = disp,
shape = as.factor(cyl),
color = as.factor(cyl))) +
geom_point(size = 4) +
geom_point(aes(fill = as.factor(cyl)), size = 2,
show.legend = FALSE) +
scale_color_brewer(name = "Cylinders", palette = "Set2") +
scale_fill_brewer(name = "Cylinders", palette = "Set2") +
scale_shape_manual(
name = "Cylinders",
values = c(1, 2, 3), # Customize shape values as needed
labels = c("4", "6", "8")
)
```
Asking chatGPT to use `scale_shape` and `solid=TRUE` gives:
``` {webr-r}
mtcars %>%
select(mpg, cyl, disp) %>%
ggplot(aes(x = mpg, y = disp,
color = as.factor(cyl),
shape = as.factor(cyl))) +
geom_point(size = 4) +
scale_color_brewer(name = "Cylinders", palette = "Set2") +
scale_shape(solid = TRUE,
name = "Cylinders",
breaks = c("4", "6", "8"),
labels = c("4", "6", "8"),
values = c(15, 16, 17),
guide = guide_legend(
override.aes =
list(fill = c("red", "blue", "green")))
)
```
.... but apparently chatGPT doesn't know how to use `scale_shape` (in the first instance), because it `scale_shape` cannot take `values` as an argument. So when I reply with the following *"I get the following error: Error: unused argument (values = c(15, 16, 17))"*, chatGPT goes back to use the 'scale_fill_manual`.
``` {webr-r}
mtcars %>%
select(mpg, cyl, disp) %>%
ggplot(aes(x = mpg, y = disp,
color = as.factor(cyl),
shape = as.factor(cyl))) +
geom_point(size = 4) +
scale_color_brewer(name = "Cylinders", palette = "Set2") +
scale_shape_manual(
name = "Cylinders",
breaks = c("4", "6", "8"),
labels = c("4", "6", "8"),
values = c(15, 16, 17)
) +
scale_fill_manual(
name = "Cylinders",
breaks = c("4", "6", "8"),
labels = c("4", "6", "8"),
values = c("red", "blue", "green")
)
```
AND FINALLY we have a nice and simple fill with one legend...... but also lots of unnecessary code. So after a few exchanges to make the code more concise this is what came out of it:
``` {webr-r}
mtcars %>%
select(mpg, cyl, disp) %>%
ggplot(aes(x = mpg, y = disp,
shape = as.factor(cyl),
color = as.factor(cyl))) +
geom_point(size = 4) +
scale_color_brewer(palette = "Set2",
name = "Cylinders") +
scale_shape_manual(name = "Cylinders",
values = c("4" = 15,
"6" = 16,
"8" = 17)) +
scale_fill_brewer(palette = "Set2",
name = "Cylinders")
```
Affter asking to use `scale_shape` instead of `scale_shape_manual`, chatGPT generates:
``` {webr-r}
mtcars %>%
select(mpg, cyl, disp) %>%
ggplot(aes(x = mpg, y = disp,
shape = as.factor(cyl),
color = as.factor(cyl))) +
geom_point(size = 4, stroke = 1) +
scale_color_brewer(palette = "Set2", name = "Cylinders") +
scale_shape(solid = TRUE, name = "Cylinders")
```
This works nicely, but chatGPT introduces `stroke = 1`, which is not needed here, so again we have unnecessary code. So after I asked *"can I leave out the stroke argument?"* we get the easiest solution and exactly the same solution as I came up with myself **without chatGPT**.
``` {webr-r}
mtcars %>%
select(mpg, cyl, disp) %>%
ggplot(aes(x = mpg, y = disp,
shape = as.factor(cyl),
color = as.factor(cyl))) +
geom_point(size = 4) +
scale_color_brewer(palette = "Set2", name = "Cylinders") +
scale_shape(solid = TRUE, name = "Cylinders")
```
Please note, that when building the ggplot example, I did use google (...off course) to get some solutions, I liked the `scale_shape` and `solid=TRUE` solution that I found, because it made the code so concise and I don't like to type in `values` and `breaks` manually.
ChatGPT use in science and coing is just dipping the toe in the water. ChatGPT is likely to better not be used as knowledge database but instead as **"reasoning or infering agents"** <https://www.nature.com/articles/s41591-023-02594-z>. ChatGPT can produce false information, also described as **"hallucinations"** <https://www.nature.com/articles/d41586-023-00816-5>, which makes it difficult to use it for getting knowledge and facts. That said, it can be used to gain knowledge and learn better coding skills. Here is a nice *quick tips* paper from PLOS computational biology on how to *"harness the power of chatGPT"* <https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1011319>.
:::