I'm plotting 32 different lines, and these lines are separated into 3 different groups according to pillarType
column in the dataset. Then for each group of curves, I'm using a different colour scale using ggnewscale
package.
On top of this, I want to overwrite the aes using guide
in order to adjust the size of and the alpha value of the points in the colour scale for better visibility.
However, when used with new_scale_color()
, guide
doesn't overwrite the original color scale, but it doesn't give an error either.
Question:
How to overwrite the color scale there are multiple color scales?
suppressMessages(library(ggnewscale))
getPalette <- function(name, n = 7) MetBrewer::met.brewer(name = name, n = n)
nDistint_type1 <- n_distinct(na.omit(dt[pillarType ==1,]$id))
nDistint_type2 <- n_distinct(na.omit(dt[pillarType ==2,]$id))
nDistint_type3 <- n_distinct(na.omit(dt[pillarType ==3,]$id))
dLabels1 <- dt[pillarType == 1, head(initRadii, 1), by = id]$V1
dLabels2 <- dt[pillarType == 2, head(initRadii, 1), by = id]$V1
dLabels3 <- dt[pillarType == 3, head(initRadii, 1), by = id]$V1
gg <- ggplot(dt, aes(x=time/3600, y=radii))
#facet_wrap(Y~., scales = "free")
geom_point(data = dt[pillarType == 1, ], aes(color = factor(id)), alpha = 0.5, size = 1)
scale_colour_manual(values = getPalette(name = "Cassatt1", n = nDistint_type1), name = "", labels = dLabels1)
geom_segment(data = dSegment, aes(x = xs, y = ys, xend = xend, yend = yend))
geom_text(data=dSegment, aes(label = label, x = xend, y = yend), hjust = 0, size = 0.36*fontSize/2)
#geom_segment(data = dSegmentInlet, aes(x = xs, y = ys, xend = xend, yend = yend))
#geom_text(data=dSegmentInlet, aes(label = label, x = xend, y = yend), hjust = 0, size = 0.36*fontSize/2)
new_scale_color()
geom_point(data = dt[pillarType == 2, ], aes(color = factor(id)), alpha = 0.5, size = 1)
scale_colour_manual(values = getPalette(name = "Hokusai2", n = nDistint_type2), name = "Initial Radius", labels = dLabels2)
new_scale_color()
geom_point(data = dt[pillarType == 3, ], aes(color = factor(id)), alpha = 0.5, size = 1)
scale_colour_manual(values = getPalette(name = "Morgenstern", n = nDistint_type3), name = "", labels = dLabels3)
new_scale_color()
labs(x = expression("Time,"~t~" [h]"), y = expression("Radius,"~r~"["*mu*m*"]"))
#scale_colour_manual(values = myPalette)
guides(colour = guide_legend(override.aes = list(linetype = list(rep("blank", nDistint_type1), rep("blank", nDistint_type2), rep("blank", nDistint_type3))
, size = list(rep(4, nDistint_type1), rep(4, nDistint_type2), rep(4, nDistint_type3))
, shape = list(rep(16, nDistint_type1), rep(16, nDistint_type2), rep(16, nDistint_type3))
, alpha = list(rep(1, nDistint_type1), rep(1, nDistint_type2), rep(1, nDistint_type3)))))
Here is the code.
Here is a small part of the dataset I'm using
structure(list(id = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L,
11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L,
24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 1L, 2L, 3L, 4L,
5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L,
19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L,
32L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L,
14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L,
27L, 28L, 29L, 30L, 31L, 32L), frame = c(0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L,
20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L,
20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L), radii = c(137.537837405087,
141.017582831663, 138.016629717733, 139.510171021776, 138.418073476597,
137.91765875681, 138.972866615784, 275.154586296369, 274.543535180656,
274.877658868984, 272.334792734823, 273.020427764398, 273.334583620086,
274.582558441549, 145.331333604796, 141.790821822185, 140.590429423558,
142.265642603543, 274.117305643615, 275.633964038963, 275.288148233074,
274.327103953659, 273.295952177652, 275.288148233074, 273.300912675065,
535.213577119783, 535.080450992816, 525.977842046906, 480.202732446329,
468.666613466323, 461.954555600678, 533.380236803606, 135.067500238506,
139.066758895244, 136.878816809704, 137.375558708568, 137.063561111172,
135.994514845125, 138.556488418068, 274.237476124644, 272.057108337957,
272.41631570908, 270.565849997608, 270.988714396078, 271.431519212961,
272.677561712585, 145.394268766791, 142.621452070766, 140.535872728916,
142.152052377914, 272.257234850042, 273.921965087325, 274.321114831676,
272.732494972556, 272.385093445621, 274.321114831676, 270.569987748154,
533.452915760479, 533.505643984437, 534.097700775748, 479.658075986754,
467.127340469522, 460.600218622949, 532.064999672349, 132.546753921209,
138.707006486231, 135.045170478007, 136.523047746809, 136.575488605484,
135.393569103307, 137.674823940128, 273.001766327868, 270.730750417704,
271.856179878479, 270.418972967786, 270.374292394063, 270.848750651969,
271.429064247826, 145.044987521408, 142.592705333536, 140.04280532829,
142.122135297991, 271.358330430047, 272.82218078793, 274.130851303634,
272.285180015404, 272.582729073697, 274.130851303634, 270.291277397846,
531.821980602914, 531.939402404158, 532.756038837906, 478.771714977616,
466.036371218215, 458.85745270572, 531.030250828604), roi_min_row = c(1223L,
1223L, 1223L, 1223L, 1223L, 1223L, 1223L, 1289L, 1289L, 1289L,
1289L, 1289L, 1289L, 1289L, 632L, 632L, 686L, 686L, 704L, 704L,
704L, 704L, 704L, 704L, 704L, 840L, 840L, 840L, 840L, 840L, 840L,
840L, 1223L, 1223L, 1223L, 1223L, 1223L, 1223L, 1223L, 1289L,
1289L, 1289L, 1289L, 1289L, 1289L, 1289L, 632L, 632L, 686L, 686L,
704L, 704L, 704L, 704L, 704L, 704L, 704L, 840L, 840L, 840L, 840L,
840L, 840L, 840L, 1223L, 1223L, 1223L, 1223L, 1223L, 1223L, 1223L,
1289L, 1289L, 1289L, 1289L, 1289L, 1289L, 1289L, 632L, 632L,
686L, 686L, 704L, 704L, 704L, 704L, 704L, 704L, 704L, 840L, 840L,
840L, 840L, 840L, 840L, 840L), roi_max_row = c(1310L, 1310L,
1310L, 1310L, 1310L, 1310L, 1310L, 1436L, 1436L, 1436L, 1436L,
1436L, 1436L, 1436L, 716L, 716L, 767L, 767L, 863L, 863L, 863L,
863L, 863L, 863L, 863L, 1150L, 1150L, 1150L, 1150L, 1150L, 1150L,
1150L, 1310L, 1310L, 1310L, 1310L, 1310L, 1310L, 1310L, 1436L,
1436L, 1436L, 1436L, 1436L, 1436L, 1436L, 716L, 716L, 767L, 767L,
863L, 863L, 863L, 863L, 863L, 863L, 863L, 1150L, 1150L, 1150L,
1150L, 1150L, 1150L, 1150L, 1310L, 1310L, 1310L, 1310L, 1310L,
1310L, 1310L, 1436L, 1436L, 1436L, 1436L, 1436L, 1436L, 1436L,
716L, 716L, 767L, 767L, 863L, 863L, 863L, 863L, 863L, 863L, 863L,
1150L, 1150L, 1150L, 1150L, 1150L, 1150L, 1150L), roi_min_col = c(1178L,
1457L, 1739L, 333L, 54L, 617L, 899L, 1030L, 1412L, 1688L, 21L,
300L, 578L, 854L, 198L, 327L, 620L, 899L, 1268L, 1556L, 159L,
1844L, 435L, 735L, 995L, 1250L, 1550L, 1790L, 370L, 650L, 80L,
950L, 1178L, 1457L, 1739L, 333L, 54L, 617L, 899L, 1030L, 1412L,
1688L, 21L, 300L, 578L, 854L, 198L, 327L, 620L, 899L, 1268L,
1556L, 159L, 1844L, 435L, 735L, 995L, 1250L, 1550L, 1790L, 370L,
650L, 80L, 950L, 1178L, 1457L, 1739L, 333L, 54L, 617L, 899L,
1030L, 1412L, 1688L, 21L, 300L, 578L, 854L, 198L, 327L, 620L,
899L, 1268L, 1556L, 159L, 1844L, 435L, 735L, 995L, 1250L, 1550L,
1790L, 370L, 650L, 80L, 950L), roi_max_col = c(1271L, 1553L,
1826L, 423L, 150L, 713L, 989L, 1439L, 1586L, 1862L, 200L, 459L,
731L, 1031L, 291L, 429L, 710L, 989L, 1439L, 1745L, 321L, 2009L,
611L, 887L, 1160L, 1550L, 1750L, 1900L, 680L, 950L, 380L, 1250L,
1271L, 1553L, 1826L, 423L, 150L, 713L, 989L, 1439L, 1586L, 1862L,
200L, 459L, 731L, 1031L, 291L, 429L, 710L, 989L, 1439L, 1745L,
321L, 2009L, 611L, 887L, 1160L, 1550L, 1750L, 1900L, 680L, 950L,
380L, 1250L, 1271L, 1553L, 1826L, 423L, 150L, 713L, 989L, 1439L,
1586L, 1862L, 200L, 459L, 731L, 1031L, 291L, 429L, 710L, 989L,
1439L, 1745L, 321L, 2009L, 611L, 887L, 1160L, 1550L, 1750L, 1900L,
680L, 950L, 380L, 1250L), isLeft = c(0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), isInlet = c(0L, 0L,
0L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
0L, 0L, 1L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 0L, 0L,
0L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
0L, 0L, 1L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 0L, 0L,
0L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
0L, 0L, 1L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 1L, 1L, 1L, 1L), time = c(0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 98.374544, 98.374544, 98.374544,
98.374544, 98.374544, 98.374544, 98.374544, 98.374544, 98.374544,
98.374544, 98.374544, 98.374544, 98.374544, 98.374544, 98.374544,
98.374544, 98.374544, 98.374544, 98.374544, 98.374544, 98.374544,
98.374544, 98.374544, 98.374544, 98.374544, 98.374544, 98.374544,
98.374544, 98.374544, 98.374544, 98.374544, 98.374544, 196.749088,
196.749088, 196.749088, 196.749088, 196.749088, 196.749088, 196.749088,
196.749088, 196.749088, 196.749088, 196.749088, 196.749088, 196.749088,
196.749088, 196.749088, 196.749088, 196.749088, 196.749088, 196.749088,
196.749088, 196.749088, 196.749088, 196.749088, 196.749088, 196.749088,
196.749088, 196.749088, 196.749088, 196.749088, 196.749088, 196.749088,
196.749088), norm_radii = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, -0.195962362572601, -0.830630248581031, -1.36622002345948,
-1.83243276943526, 0, 0, 0, 0, 0, 0, 0, 0, 0, -8.11985872884111,
-1.97754388573316, -0.762811536170318, 0, 0, -2.47033716658058,
-1.95082393641883, -1.13781290802831, -2.13461231320846, -1.35451236542525,
-1.92314391168432, -0.416378197716, -0.917110171724516, -2.48642684269896,
-2.46134315990446, -1.76894273721518, -2.03171336832008, -1.90306440712493,
-1.90499672896385, -0.133027200577146, 0, -1.42077671810162,
-1.94602299506383, -1.86007079357211, -1.71199895163875, -0.967033401398567,
-1.59460898110359, -0.910858732030306, -0.967033401398567, -2.73092492691097,
-1.76066135930353, -1.57480700837834, 0, -2.52220034530797, -2.30208453297161,
-1.35433697772976, -1.31523713125671, -4.99108348387765, -2.31057634543205,
-2.97145923972542, -2.98712327496727, -1.84258487111313, -2.52408965350213,
-1.29804267565555, -2.15281996850064, -3.81278476295267, -3.02147899050476,
-1.91581976703719, -2.64613537033512, -2.48583296811694, -3.15349419372308,
-0.482308445960342, -0.0287467372300227, -1.91384411872806, -1.97594007498725,
-2.7589752135674, -2.81178325103366, -1.15729692944063, -2.04192393825565,
-0.713223103954817, -1.15729692944063, -3.00963527721882, -3.39159651686907,
-3.14104858865778, -1.34166193784176, -3.40856135444625, -3.39305378427906,
-3.09710289495843, -2.34998597500169), volume = c(7566662.68722722,
7954383.46707395, 7619436.03145668, 7785235.1274101, 7663825.22598902,
7608512.2387839, 7725383.06216335, 30284018.5439703, 30149661.0837969,
30223090.9381175, 29666495.7335676, 29816061.5906619, 29884717.8411064,
30158232.5601227, 8448478.61093936, 8041854.86120423, 7906267.53820023,
8095805.22615962, 30056118.9013259, 30389632.8527331, 30313425.823038,
30102143.9854407, 29876270.9906757, 30313425.823038, 29877355.5476093,
114581429.253342, 114524435.61387, 110661076.129728, 92237865.6995682,
87859357.8311969, 85360804.5760881, 113797790.805068, 7297291.84827154,
7735825.37185117, 7494324.19648984, 7548817.65219646, 7514567.91379035,
7397803.22718439, 7679160.19309844, 30082477.3244859, 29606028.0788844,
29684259.6258036, 29282351.6739712, 29373953.3320155, 29470027.8489025,
29741221.0646083, 8455797.35609196, 8136351.43630951, 7900132.60947126,
8082882.39810134, 29649600.7712765, 30013297.1829206, 30100829.6169973,
29753205.5255821, 29677455.6525519, 30100829.6169973, 29283247.3080144,
113828805.333343, 113851308.8653, 114104141.589576, 92028747.9437259,
87283180.8856515, 84861024.5582032, 113237265.550535, 7027456.79001982,
7695853.4593485, 7294879.22777361, 7455417.02643099, 7461145.63513064,
7332567.42181283, 7581742.85877811, 29811985.7672543, 29318055.6886932,
29562313.0152481, 29250568.3763808, 29240903.195036, 29343618.2918931,
29469494.7673802, 8415219.36203415, 8133071.84573463, 7844794.92968692,
8079480.53666419, 29454137.3975131, 29772776.9319527, 30059089.4545819,
29655687.7024083, 29720537.6757057, 30059089.4545819, 29222949.8549437,
113133847.620962, 113183811.132037, 113531598.767302, 91688942.025043,
86875959.7192966, 84220064.7614328, 112797250.918036), initRadii = c(137L,
141L, 138L, 139L, 138L, 137L, 138L, 275L, 274L, 274L, 272L, 273L,
273L, 274L, 145L, 141L, 140L, 142L, 274L, 275L, 275L, 274L, 273L,
275L, 273L, 535L, 535L, 525L, 480L, 468L, 461L, 533L, 137L, 141L,
138L, 139L, 138L, 137L, 138L, 275L, 274L, 274L, 272L, 273L, 273L,
274L, 145L, 141L, 140L, 142L, 274L, 275L, 275L, 274L, 273L, 275L,
273L, 535L, 535L, 525L, 480L, 468L, 461L, 533L, 137L, 141L, 138L,
139L, 138L, 137L, 138L, 275L, 274L, 274L, 272L, 273L, 273L, 274L,
145L, 141L, 140L, 142L, 274L, 275L, 275L, 274L, 273L, 275L, 273L,
535L, 535L, 525L, 480L, 468L, 461L, 533L), pillarType = c(3L,
3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L,
3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L,
3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L,
3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L),
intercept = c(132.511531315291, 139.579930613576, 138.796491768489,
142.365617608476, 136.138495055024, 138.864911611929, 141.816993690037,
271.286300641114, 270.00053046437, 271.163199699451, 272.543316491073,
270.729587887096, 271.157245643305, 269.166980759566, 145.076308306797,
143.104039778109, 146.192710050839, 151.722873430934, 275.899902544433,
275.804554684105, 280.078840513332, 279.180835957369, 281.546216329144,
280.078840513332, 279.607408209592, 514.721535864255, 519.183630800621,
529.682079553976, 495.225301697784, 467.097508702566, 456.613080385902,
516.109821272962, 132.511531315291, 139.579930613576, 138.796491768489,
142.365617608476, 136.138495055024, 138.864911611929, 141.816993690037,
271.286300641114, 270.00053046437, 271.163199699451, 272.543316491073,
270.729587887096, 271.157245643305, 269.166980759566, 145.076308306797,
143.104039778109, 146.192710050839, 151.722873430934, 275.899902544433,
275.804554684105, 280.078840513332, 279.180835957369, 281.546216329144,
280.078840513332, 279.607408209592, 514.721535864255, 519.183630800621,
529.682079553976, 495.225301697784, 467.097508702566, 456.613080385902,
516.109821272962, 132.511531315291, 139.579930613576, 138.796491768489,
142.365617608476, 136.138495055024, 138.864911611929, 141.816993690037,
271.286300641114, 270.00053046437, 271.163199699451, 272.543316491073,
270.729587887096, 271.157245643305, 269.166980759566, 145.076308306797,
143.104039778109, 146.192710050839, 151.722873430934, 275.899902544433,
275.804554684105, 280.078840513332, 279.180835957369, 281.546216329144,
280.078840513332, 279.607408209592, 514.721535864255, 519.183630800621,
529.682079553976, 495.225301697784, 467.097508702566, 456.613080385902,
516.109821272962), slope = c(-0.0101037726461794, -0.0131951879521286,
-0.0141596693641466, -0.0116109480016573, -0.010182399013147,
-0.0108196845518608, -0.0123247206534021, -0.011420458646203,
-0.0128540695010234, -0.0143312040913922, -0.0121073229017879,
-0.0104853323212145, -0.0107745966472918, -0.0106097866771993,
-0.000173040753665412, -0.000781870426736846, -0.00170014826613898,
-0.0030650146824384, -0.005307758910803, -0.00731801881780808,
-0.00395552626025067, -0.0104126168689337, -0.00406531811842555,
-0.00395552626025067, -0.00499797868785912, -0.00489984638883251,
-0.00712158879659282, -0.0112078271167017, -0.00597029458094535,
-0.00486038580880774, -0.00541446249268685, -0.00494110693106258,
-0.0101037726461794, -0.0131951879521286, -0.0141596693641466,
-0.0116109480016573, -0.010182399013147, -0.0108196845518608,
-0.0123247206534021, -0.011420458646203, -0.0128540695010234,
-0.0143312040913922, -0.0121073229017879, -0.0104853323212145,
-0.0107745966472918, -0.0106097866771993, -0.000173040753665412,
-0.000781870426736846, -0.00170014826613898, -0.0030650146824384,
-0.005307758910803, -0.00731801881780808, -0.00395552626025067,
-0.0104126168689337, -0.00406531811842555, -0.00395552626025067,
-0.00499797868785912, -0.00489984638883251, -0.00712158879659282,
-0.0112078271167017, -0.00597029458094535, -0.00486038580880774,
-0.00541446249268685, -0.00494110693106258, -0.0101037726461794,
-0.0131951879521286, -0.0141596693641466, -0.0116109480016573,
-0.010182399013147, -0.0108196845518608, -0.0123247206534021,
-0.011420458646203, -0.0128540695010234, -0.0143312040913922,
-0.0121073229017879, -0.0104853323212145, -0.0107745966472918,
-0.0106097866771993, -0.000173040753665412, -0.000781870426736846,
-0.00170014826613898, -0.0030650146824384, -0.005307758910803,
-0.00731801881780808, -0.00395552626025067, -0.0104126168689337,
-0.00406531811842555, -0.00395552626025067, -0.00499797868785912,
-0.00489984638883251, -0.00712158879659282, -0.0112078271167017,
-0.00597029458094535, -0.00486038580880774, -0.00541446249268685,
-0.00494110693106258), mean_intercept = c(278.220206932652,
278.220206932652, 278.220206932652, 278.220206932652, 278.220206932652,
278.220206932652, 278.220206932652, 278.220206932652, 278.220206932652,
278.220206932652, 278.220206932652, 278.220206932652, 278.220206932652,
278.220206932652, 278.220206932652, 278.220206932652, 278.220206932652,
278.220206932652, 278.220206932652, 278.220206932652, 278.220206932652,
278.220206932652, 278.220206932652, 278.220206932652, 278.220206932652,
278.220206932652, 278.220206932652, 278.220206932652, 278.220206932652,
278.220206932652, 278.220206932652, 278.220206932652, 278.220206932652,
278.220206932652, 278.220206932652, 278.220206932652, 278.220206932652,
278.220206932652, 278.220206932652, 278.220206932652, 278.220206932652,
278.220206932652, 278.220206932652, 278.220206932652, 278.220206932652,
278.220206932652, 278.220206932652, 278.220206932652, 278.220206932652,
278.220206932652, 278.220206932652, 278.220206932652, 278.220206932652,
278.220206932652, 278.220206932652, 278.220206932652, 278.220206932652,
278.220206932652, 278.220206932652, 278.220206932652, 278.220206932652,
278.220206932652, 278.220206932652, 278.220206932652, 278.220206932652,
278.220206932652, 278.220206932652, 278.220206932652, 278.220206932652,
278.220206932652, 278.220206932652, 278.220206932652, 278.220206932652,
278.220206932652, 278.220206932652, 278.220206932652, 278.220206932652,
278.220206932652, 278.220206932652, 278.220206932652, 278.220206932652,
278.220206932652, 278.220206932652, 278.220206932652, 278.220206932652,
278.220206932652, 278.220206932652, 278.220206932652, 278.220206932652,
278.220206932652, 278.220206932652, 278.220206932652, 278.220206932652,
278.220206932652, 278.220206932652, 278.220206932652), std_intercept = c(133.779472529883,
133.779472529883, 133.779472529883, 133.779472529883, 133.779472529883,
133.779472529883, 133.779472529883, 133.779472529883, 133.779472529883,
133.779472529883, 133.779472529883, 133.779472529883, 133.779472529883,
133.779472529883, 133.779472529883, 133.779472529883, 133.779472529883,
133.779472529883, 133.779472529883, 133.779472529883, 133.779472529883,
133.779472529883, 133.779472529883, 133.779472529883, 133.779472529883,
133.779472529883, 133.779472529883, 133.779472529883, 133.779472529883,
133.779472529883, 133.779472529883, 133.779472529883, 133.779472529883,
133.779472529883, 133.779472529883, 133.779472529883, 133.779472529883,
133.779472529883, 133.779472529883, 133.779472529883, 133.779472529883,
133.779472529883, 133.779472529883, 133.779472529883, 133.779472529883,
133.779472529883, 133.779472529883, 133.779472529883, 133.779472529883,
133.779472529883, 133.779472529883, 133.779472529883, 133.779472529883,
133.779472529883, 133.779472529883, 133.779472529883, 133.779472529883,
133.779472529883, 133.779472529883, 133.779472529883, 133.779472529883,
133.779472529883, 133.779472529883, 133.779472529883, 133.779472529883,
133.779472529883, 133.779472529883, 133.779472529883, 133.779472529883,
133.779472529883, 133.779472529883, 133.779472529883, 133.779472529883,
133.779472529883, 133.779472529883, 133.779472529883, 133.779472529883,
133.779472529883, 133.779472529883, 133.779472529883, 133.779472529883,
133.779472529883, 133.779472529883, 133.779472529883, 133.779472529883,
133.779472529883, 133.779472529883, 133.779472529883, 133.779472529883,
133.779472529883, 133.779472529883, 133.779472529883, 133.779472529883,
133.779472529883, 133.779472529883, 133.779472529883), mean_slope = c(-0.00797273384804919,
-0.00797273384804919, -0.00797273384804919, -0.00797273384804919,
-0.00797273384804919, -0.00797273384804919, -0.00797273384804919,
-0.00797273384804919, -0.00797273384804919, -0.00797273384804919,
-0.00797273384804919, -0.00797273384804919, -0.00797273384804919,
-0.00797273384804919, -0.00797273384804919, -0.00797273384804919,
-0.00797273384804919, -0.00797273384804919, -0.00797273384804919,
-0.00797273384804919, -0.00797273384804919, -0.00797273384804919,
-0.00797273384804919, -0.00797273384804919, -0.00797273384804919,
-0.00797273384804919, -0.00797273384804919, -0.00797273384804919,
-0.00797273384804919, -0.00797273384804919, -0.00797273384804919,
-0.00797273384804919, -0.00797273384804919, -0.00797273384804919,
-0.00797273384804919, -0.00797273384804919, -0.00797273384804919,
-0.00797273384804919, -0.00797273384804919, -0.00797273384804919,
-0.00797273384804919, -0.00797273384804919, -0.00797273384804919,
-0.00797273384804919, -0.00797273384804919, -0.00797273384804919,
-0.00797273384804919, -0.00797273384804919, -0.00797273384804919,
-0.00797273384804919, -0.00797273384804919, -0.00797273384804919,
-0.00797273384804919, -0.00797273384804919, -0.00797273384804919,
-0.00797273384804919, -0.00797273384804919, -0.00797273384804919,
-0.00797273384804919, -0.00797273384804919, -0.00797273384804919,
-0.00797273384804919, -0.00797273384804919, -0.00797273384804919,
-0.00797273384804919, -0.00797273384804919, -0.00797273384804919,
-0.00797273384804919, -0.00797273384804919, -0.00797273384804919,
-0.00797273384804919, -0.00797273384804919, -0.00797273384804919,
-0.00797273384804919, -0.00797273384804919, -0.00797273384804919,
-0.00797273384804919, -0.00797273384804919, -0.00797273384804919,
-0.00797273384804919, -0.00797273384804919, -0.00797273384804919,
-0.00797273384804919, -0.00797273384804919, -0.00797273384804919,
-0.00797273384804919, -0.00797273384804919, -0.00797273384804919,
-0.00797273384804919, -0.00797273384804919, -0.00797273384804919,
-0.00797273384804919, -0.00797273384804919, -0.00797273384804919,
-0.00797273384804919, -0.00797273384804919), std_slope = c(0.00411735481925265,
0.00411735481925265, 0.00411735481925265, 0.00411735481925265,
0.00411735481925265, 0.00411735481925265, 0.00411735481925265,
0.00411735481925265, 0.00411735481925265, 0.00411735481925265,
0.00411735481925265, 0.00411735481925265, 0.00411735481925265,
0.00411735481925265, 0.00411735481925265, 0.00411735481925265,
0.00411735481925265, 0.00411735481925265, 0.00411735481925265,
0.00411735481925265, 0.00411735481925265, 0.00411735481925265,
0.00411735481925265, 0.00411735481925265, 0.00411735481925265,
0.00411735481925265, 0.00411735481925265, 0.00411735481925265,
0.00411735481925265, 0.00411735481925265, 0.00411735481925265,
0.00411735481925265, 0.00411735481925265, 0.00411735481925265,
0.00411735481925265, 0.00411735481925265, 0.00411735481925265,
0.00411735481925265, 0.00411735481925265, 0.00411735481925265,
0.00411735481925265, 0.00411735481925265, 0.00411735481925265,
0.00411735481925265, 0.00411735481925265, 0.00411735481925265,
0.00411735481925265, 0.00411735481925265, 0.00411735481925265,
0.00411735481925265, 0.00411735481925265, 0.00411735481925265,
0.00411735481925265, 0.00411735481925265, 0.00411735481925265,
0.00411735481925265, 0.00411735481925265, 0.00411735481925265,
0.00411735481925265, 0.00411735481925265, 0.00411735481925265,
0.00411735481925265, 0.00411735481925265, 0.00411735481925265,
0.00411735481925265, 0.00411735481925265, 0.00411735481925265,
0.00411735481925265, 0.00411735481925265, 0.00411735481925265,
0.00411735481925265, 0.00411735481925265, 0.00411735481925265,
0.00411735481925265, 0.00411735481925265, 0.00411735481925265,
0.00411735481925265, 0.00411735481925265, 0.00411735481925265,
0.00411735481925265, 0.00411735481925265, 0.00411735481925265,
0.00411735481925265, 0.00411735481925265, 0.00411735481925265,
0.00411735481925265, 0.00411735481925265, 0.00411735481925265,
0.00411735481925265, 0.00411735481925265, 0.00411735481925265,
0.00411735481925265, 0.00411735481925265, 0.00411735481925265,
0.00411735481925265, 0.00411735481925265)), row.names = c(NA,
-96L), class = c("data.table", "data.frame"), .internal.selfref = <pointer: 0x7feefb81dce0>, sorted = "frame")
CodePudding user response:
When working with ggnewscale
it's best or you have to do adjustments of the color scales directly via the scale, i.e. in your case via the guide
argument of the scale:
guide1 <- guide_legend(override.aes = list(
linetype = rep("blank", nDistint_type1),
size = rep(4, nDistint_type1),
shape = rep(16, nDistint_type1),
alpha = rep(1, nDistint_type1)
))
guide2 <- guide_legend(override.aes = list(
linetype = rep("blank", nDistint_type2),
size = rep(4, nDistint_type2),
shape = rep(16, nDistint_type2),
alpha = rep(1, nDistint_type2)
))
guide3 <- guide_legend(override.aes = list(
linetype = rep("blank", nDistint_type3),
size = rep(4, nDistint_type3),
shape = rep(16, nDistint_type3),
alpha = rep(1, nDistint_type3)
))
ggplot(dt, aes(x = time / 3600, y = radii))
geom_point(data = dt[pillarType == 1, ], aes(color = factor(id)), alpha = 0.5, size = 1)
scale_colour_manual(values = getPalette(name = "Cassatt1", n = nDistint_type1), name = "", labels = dLabels1,
guide = guide1)
new_scale_color()
geom_point(data = dt[pillarType == 2, ], aes(color = factor(id)), alpha = 0.5, size = 1)
scale_colour_manual(values = getPalette(name = "Hokusai2", n = nDistint_type2), name = "Initial Radius", labels = dLabels2,
guide = guide2)
new_scale_color()
geom_point(data = dt[pillarType == 3, ], aes(color = factor(id)), alpha = 0.5, size = 1)
scale_colour_manual(values = getPalette(name = "Morgenstern", n = nDistint_type3), name = "", labels = dLabels3,
guide = guide3)
labs(x = expression("Time," ~ t ~ " [h]"), y = expression("Radius," ~ r ~ "[" * mu * m * "]"))