Dear R users,
I have a (melted) data frame of several metal prices from 1980. I want to
make a time series plot for each metal price. By default ggplot constructs
single plot for all prices. Adding +facet_grid(variable~.) makes for each
metal price a plot, but now there is another problem - scale of y axis.
Some metals have price $1000 and some $2. Because ggplot makes same y scale
for each metal, some metal prices printed as straight horizontal line. What
is the command to make for each plot specific y axis scale?
Currently I am trying command:
ggplot(data=melted2, aes(x=date, y=value, group=variable,
color=variable))+geom_line()+facet_grid(variable~.)
Best regards,
Maxim
P.S dput
structure(list(date = structure(c(3652, 3683, 3712, 3743, 3773,
3804, 3834, 3865, 3896, 3926, 3957, 3987, 4018, 4049, 4077, 4108,
4138, 4169, 4199, 4230, 4261, 4291, 4322, 4352, 4383, 4414, 4442,
4473, 4503, 4534, 4564, 4595, 4626, 4656, 4687, 4717, 4748, 4779,
4807, 4838, 4868, 4899, 4929, 4960, 4991, 5021, 5052, 5082, 5113,
5144, 5173, 5204, 5234, 5265, 5295, 5326, 5357, 5387, 5418, 5448,
5479, 5510, 5538, 5569, 5599, 5630, 5660, 5691, 5722, 5752, 5783,
5813, 5844, 5875, 5903, 5934, 5964, 5995, 6025, 6056, 6087, 6117,
6148, 6178, 6209, 6240, 6268, 6299, 6329, 6360, 6390, 6421, 6452,
6482, 6513, 6543, 6574, 6605, 6634, 6665, 6695, 6726, 6756, 6787,
6818, 6848, 6879, 6909, 6940, 6971, 6999, 7030, 7060, 7091, 7121,
7152, 7183, 7213, 7244, 7274, 7305, 7336, 7364, 7395, 7425, 7456,
7486, 7517, 7548, 7578, 7609, 7639, 7670, 7701, 7729, 7760, 7790,
7821, 7851, 7882, 7913, 7943, 7974, 8004, 8035, 8066, 8095, 8126,
8156, 8187, 8217, 8248, 8279, 8309, 8340, 8370, 8401, 8432, 8460,
8491, 8521, 8552, 8582, 8613, 8644, 8674, 8705, 8735, 8766, 8797,
8825, 8856, 8886, 8917, 8947, 8978, 9009, 9039, 9070, 9100, 9131,
9162, 9190, 9221, 9251, 9282, 9312, 9343, 9374, 9404, 9435, 9465,
9496, 9527, 9556, 9587, 9617, 9648, 9678, 9709, 9740, 9770, 9801,
9831, 9862, 9893, 9921, 9952, 9982, 10013, 10043, 10074, 10105,
10135, 10166, 10196, 10227, 10258, 10286, 10317, 10347, 10378,
10408, 10439, 10470, 10500, 10531, 10561, 10592, 10623, 10651,
10682, 10712, 10743, 10773, 10804, 10835, 10865, 10896, 10926,
10957, 10988, 11017, 11048, 11078, 11109, 11139, 11170, 11201,
11231, 11262, 11292, 11323, 11354, 11382, 11413, 11443, 11474,
11504, 11535, 11566, 11596, 11627, 11657, 11688, 11719, 11747,
11778, 11808, 11839, 11869, 11900, 11931, 11961, 11992, 12022,
12053, 12084, 12112, 12143, 12173, 12204, 12234, 12265, 12296,
12326, 12357, 12387, 12418, 12449, 12478, 12509, 12539, 12570,
12600, 12631, 12662, 12692, 12723, 12753, 12784, 12815, 12843,
12874, 12904, 12935, 12965, 12996, 13027, 13057, 13088, 13118,
13149, 13180, 13208, 13239, 13269, 13300, 13330, 13361, 13392,
13422, 13453, 13483, 13514, 13545, 13573, 13604, 13634, 13665,
13695, 13726, 13757, 13787, 13818, 13848, 13879, 13910, 13939,
13970, 14000, 14031, 14061, 14092, 14123, 14153, 14184, 14214,
14245, 14276, 14304, 14335, 14365, 14396, 14426, 14457, 14488,
14518, 14549, 14579, 14610, 14641, 14669, 14700, 14730, 14761,
14791, 14822, 14853, 14883, 14914, 14944, 14975, 15006, 15034,
15065, 15095, 15126, 15156, 15187, 15218, 15248, 15279, 15309,
15340, 15371, 15400, 15431, 15461, 15492, 15522, 15553, 15584,
15614, 15645, 15675, 15706, 15737, 15765, 15796, 15826, 15857,
15887, 15918, 15949, 15979, 16010, 16040, 16071, 16102, 16130,
16161, 16191, 16222, 16252, 16283, 16314, 16344, 16375, 16405,
16436, 16467, 16495, 16526, 16556, 16587, 16617, 16648, 16679,
16709, 16740, 3652, 3683, 3712, 3743, 3773, 3804, 3834, 3865,
3896, 3926, 3957, 3987, 4018, 4049, 4077, 4108, 4138, 4169, 4199,
4230, 4261, 4291, 4322, 4352, 4383, 4414, 4442, 4473, 4503, 4534,
4564, 4595, 4626, 4656, 4687, 4717, 4748, 4779, 4807, 4838, 4868,
4899, 4929, 4960, 4991, 5021, 5052, 5082, 5113, 5144, 5173, 5204,
5234, 5265, 5295, 5326, 5357, 5387, 5418, 5448, 5479, 5510, 5538,
5569, 5599, 5630, 5660, 5691, 5722, 5752, 5783, 5813, 5844, 5875,
5903, 5934, 5964, 5995, 6025, 6056, 6087, 6117, 6148, 6178, 6209,
6240, 6268, 6299, 6329, 6360, 6390, 6421, 6452, 6482, 6513, 6543,
6574, 6605, 6634, 6665, 6695, 6726, 6756, 6787, 6818, 6848, 6879,
6909, 6940, 6971, 6999, 7030, 7060, 7091, 7121, 7152, 7183, 7213,
7244, 7274, 7305, 7336, 7364, 7395, 7425, 7456, 7486, 7517, 7548,
7578, 7609, 7639, 7670, 7701, 7729, 7760, 7790, 7821, 7851, 7882,
7913, 7943, 7974, 8004, 8035, 8066, 8095, 8126, 8156, 8187, 8217,
8248, 8279, 8309, 8340, 8370, 8401, 8432, 8460, 8491, 8521, 8552,
8582, 8613, 8644, 8674, 8705, 8735, 8766, 8797, 8825, 8856, 8886,
8917, 8947, 8978, 9009, 9039, 9070, 9100, 9131, 9162, 9190, 9221,
9251, 9282, 9312, 9343, 9374, 9404, 9435, 9465, 9496, 9527, 9556,
9587, 9617, 9648, 9678, 9709, 9740, 9770, 9801, 9831, 9862, 9893,
9921, 9952, 9982, 10013, 10043, 10074, 10105, 10135, 10166, 10196,
10227, 10258, 10286, 10317, 10347, 10378, 10408, 10439, 10470,
10500, 10531, 10561, 10592, 10623, 10651, 10682, 10712, 10743,
10773, 10804, 10835, 10865, 10