tidyLPA的函数plot_profiles
得到了一个选项add_line
,用于在表示类的点之间创建线。我想改变linewidth
,但找不到这样做的方法。
我已经找到了一种方法来改变linetype
与ggplot-function scale_linetype_manual
。我想也许函数scale_linewidth_manual
可以解决我的问题,但它没有(scale_size_manual
也没有)。下面是R中的MWE,我使用scale_linetype_manual
-函数来证明它的工作原理:
library(tidyLPA)
library(ggplot2)
# Calculating the model
test <- data %>%
estimate_profiles(n_profiles=4, models=2)
# Plotting the profiles
plot_profiles(test, add_line=TRUE, ci=NULL, sd=FALSE) +
scale_linetype_manual(values=c('solid','solid','solid','solid'))
字符串
样本数据(6个变量的55个观察结果):
Var1 Var2 Var3 Var4 Var5 Var6
11,78772549 0,515414718 12,02634342 17,7436289 39,35286819 1,259902644
44,32029795 14,56005587 15,20018622 10,85893855 9,79981378 4,213221601
9,580069346 0,3210479 4,006677796 19,42981893 62,36034416 0,526518557
48,40924092 0 1,927392739 3,801980198 44,23762376 0,158415842
51,11242955 6,021951943 1,997429052 1,058044102 21,29931771 3,559774548
0 0 31,03368177 13,19396051 55,14518002 0
26,47639739 55,92534071 0,059253407 1,718348805 6,656132728 8,255974719
6,379700021 9,143209369 37,37415246 11,00267105 20,77254983 0,369837682
42,23989397 0 30,78860172 5,752153744 15,49370444 0,251822399
24,77972075 17,12078081 0,786227464 4,785143012 45,64185983 2,806018707
17,4403514 0,189677548 47,92852151 9,234301687 23,96925227 0,628930818
41,76017602 0 6,98569857 5,423542354 18,47084708 0,693069307
0 28,87874837 50,79530639 4,367666232 13,08996089 1,225554107
24,21186518 5,732715545 26,86472245 5,323884801 20,30526029 16,5621877
0 6,902754356 60,24732996 20,12366498 10,65767285 1,652613828
11,985283 20,86084371 12,74129328 0,806410967 49,32211078 0,826571241
6,177422425 0 25,59489815 14,96287836 35,86521987 0,095183705
22,6010578 0 18,879864 8,859085757 45,85379675 0,406120136
18,83255633 18,63830614 31,84731935 3,797591298 24,67948718 1,621989122
22,83526409 27,67524053 9,974474769 4,142941292 31,45493815 1,89475751
0 0 32,56837099 28,26397146 38,25208086 0
1,645854015 0 38,97800303 5,569778985 26,84570772 0
0 0 0 21,79535586 62,96960544 0,066075137
0 0 20,42465239 12,8147313 64,76888388 0
8,233320428 31,242741 10,20776874 4,658665634 14,07923603 24,80965286
9,027190332 70,33232628 0,410876133 2,380664653 14,50151057 2,598187311
0 5,163304515 65,46589817 0 28,20605187 0,240153698
33,26230556 8,523332623 6,296611975 9,705945025 39,07948008 1,214574899
58,85867577 0,86574808 3,536154128 1,719302524 21,07060115 1,329106207
53,71741229 0 5,29986053 0 26,73532883 0,107284626
28,41890711 30,58332525 5,445016015 3,202950597 4,979132292 2,135300398
62,71820449 7,197914305 7,526637951 8,716844253 12,37814555 0,974835638
64,44352389 0 4,791494062 0 16,44573322 4,901960784
37,12824399 0 22,60844857 1,733282819 17,25705626 3,551809055
33,0634278 2,932973459 29,98650472 7,494376968 25,55105713 0,296896086
28,35849787 10,87882307 7,326751839 11,93379791 17,63453349 1,074332172
5,458967661 0 11,6926403 11,01702549 44,96892172 0,207188542
27,81524627 47,05702023 0,766400981 0,316779072 5,354588187 17,93378296
8,113275182 61,83534472 0 3,369578205 21,42430398 4,182100609
43,46482458 0 3,035811671 1,872386839 46,48245773 2,290492638
0 0 45,78503688 13,93572181 36,98630137 0
49,33636708 0 17,59575275 7,413727721 24,16571862 0
0 0 16,66666667 18,95996781 59,66606317 0,070408369
31,14656507 7,060364329 7,524705322 9,477318728 41,93356352 0,916775807
31,75187457 8,411724608 26,24403545 11,38377641 18,22767553 2,45398773
22,60183968 10,43739441 9,846067205 13,07490145 40,60446781 1,454852638
35,20227111 21,0314644 16,44192098 4,163709487 19,3281287 3,016323634
21,58402725 41,9000757 13,45571537 2,602195307 7,721423164 9,424678274
19,9943757 0 35,7424072 10,09561305 31,46794151 0,112485939
0 0 8,210689388 9,775367932 80,4182804 0
2,15450908 3,878116343 13,01939058 3,816558941 28,73191751 4,60141582
0,280091928 0,574547544 29,13674232 18,3208848 41,19505889 3,267739155
27,9080809 1,728230937 30,78530054 7,786534992 23,33111765 0,949577438
0 18,77560858 29,35044589 9,954205833 38,75030128 2,452398168
31,17784451 0 13,08641975 7,280613947 32,06539873 0,14681348
型
1条答案
按热度按时间8mmmxcuj1#
函数
plot_profiles
输出一个ggplot对象,scale_linetype_manual
工作的原因是linetype
美学已经Map到Class
。linewidth
的美感 * 未 * Map,因此scale_linewidth_manual
函数将 * 无法 * 工作,除非您使用aes
函数自己Map此美感。如果希望所有线宽大小相同,可以将
linewidth
Map到所需的数值,并使用scale_linewidth_identity
:字符串
的数据
另请注意,如果要在按下按键时保存,也可以对线型执行相同的操作:
型
如果需要不同大小的线宽,可以Map到
Class
并使用scale_linewidth_manual
型
的