Created
May 27, 2011 15:01
-
-
Save 1beb/995423 to your computer and use it in GitHub Desktop.
Doubly Y Axis Plots with Base (Daily Currency Data)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x <- structure(list(date = structure(c(14613, 14614, 14615, 14616, | |
14617, 14620, 14621, 14622, 14623, 14624, 14627, 14628, 14629, | |
14630, 14631, 14634, 14635, 14636, 14637, 14638, 14641, 14642, | |
14643, 14644, 14645, 14648, 14649, 14650, 14651, 14652, 14655, | |
14656, 14657, 14658, 14659, 14662, 14663, 14664, 14665, 14666, | |
14669, 14670, 14671, 14672, 14673, 14676, 14677, 14678, 14679, | |
14680, 14683, 14684, 14685, 14686, 14687, 14690, 14691, 14692, | |
14693, 14694, 14697, 14698, 14699, 14700, 14701, 14704, 14705, | |
14706, 14707, 14708, 14711, 14712, 14713, 14714, 14715, 14718, | |
14719, 14720, 14721, 14722, 14725, 14726, 14727, 14728, 14729, | |
14732, 14733, 14734, 14735, 14736, 14739, 14740, 14741, 14742, | |
14743, 14746, 14747, 14748, 14749, 14750, 14753, 14754, 14755, | |
14756, 14757, 14760, 14761, 14762, 14763, 14764, 14767, 14768, | |
14769, 14770, 14771, 14774, 14775, 14776, 14777, 14778, 14781, | |
14782, 14783, 14784, 14785, 14788, 14789, 14790), class = "Date"), | |
usd = c(1.0378, 1.0372, 1.0334, 1.0351, 1.0344, 1.0317, 1.0375, | |
1.0322, 1.0261, 1.0287, 1.0251, 1.0328, 1.0478, 1.0487, 1.0564, | |
1.0582, 1.0606, 1.0657, 1.0643, 1.065, 1.0653, 1.0607, 1.0609, | |
1.0734, 1.0725, 1.0692, 1.069, 1.0671, 1.0523, 1.0531, 1.048, | |
1.0426, 1.0455, 1.0452, 1.042, 1.0428, 1.0517, 1.055, 1.0675, | |
1.0526, 1.0421, 1.0326, 1.0287, 1.0309, 1.0286, 1.0286, 1.0251, | |
1.0243, 1.0265, 1.0187, 1.0217, 1.0148, 1.0113, 1.0139, 1.0155, | |
1.0193, 1.0178, 1.0267, 1.0188, 1.0285, 1.0203, 1.0188, 1.0156, | |
1.0075, NA, 1.0025, 1.0001, 1.003, 1.002, 1.0055, 1.0015, | |
1.0028, 0.9961, 1.0014, 1.0148, 1.0201, 0.9986, 0.9984, 1.0013, | |
1.0027, 1.0009, 1.0173, 1.0128, 1.0054, 1.0116, 1.0134, 1.0216, | |
1.0266, 1.0437, 1.0431, 1.0246, 1.0195, 1.0201, 1.0149, 1.0344, | |
1.0405, 1.033, 1.0515, 1.0659, 1.057, NA, 1.0778, 1.0651, | |
1.0496, 1.0499, 1.0462, 1.0479, 1.0404, 1.0416, 1.0516, 1.054, | |
1.0518, 1.0395, 1.0337, 1.0333, 1.0253, 1.0288, 1.0236, 1.0284, | |
1.0238, 1.0199, 1.0201, 1.0434, 1.0432, 1.037, 1.0337, 1.0529, | |
1.0606), euro = c(1.4963, 1.4937, 1.4884, 1.4816, 1.485, | |
1.4995, 1.5067, 1.4958, 1.4855, 1.479, 1.4752, 1.4736, 1.4767, | |
1.4792, 1.4951, 1.4969, 1.4937, 1.4975, 1.4881, 1.4772, 1.4812, | |
1.4802, 1.4753, 1.4769, 1.4594, 1.4646, 1.4747, 1.4642, 1.4351, | |
1.4348, 1.4259, 1.4326, 1.4242, 1.4175, 1.4106, 1.4171, 1.4237, | |
1.4322, 1.4384, 1.4377, 1.4084, 1.4005, 1.4125, 1.3989, 1.3996, | |
1.4002, 1.3927, 1.3989, 1.4034, 1.4011, 1.3948, 1.3962, 1.3894, | |
1.3791, 1.374, 1.3791, 1.3775, 1.3703, 1.3595, 1.378, 1.3738, | |
1.3661, 1.3737, 1.3671, NA, 1.352, 1.3378, 1.3403, 1.3386, | |
1.3541, 1.3606, 1.3618, 1.3612, 1.3559, 1.3687, 1.3727, 1.3426, | |
1.336, 1.3314, 1.3397, 1.3347, 1.3459, 1.3298, 1.3314, 1.3456, | |
1.3359, 1.3319, 1.3233, 1.3244, 1.3266, 1.3177, 1.2963, 1.2895, | |
1.2755, 1.2817, 1.2797, 1.2766, 1.2951, 1.3185, 1.3291, NA, | |
1.3234, 1.302, 1.2983, 1.2985, 1.2843, 1.2853, 1.2698, 1.27, | |
1.2617, 1.2603, 1.2614, 1.252, 1.2518, 1.2478, 1.2587, 1.2682, | |
1.2613, 1.2716, 1.2653, 1.2631, 1.2549, 1.2753, 1.2898, 1.2787, | |
1.2731, 1.283, 1.3035)), .Names = c("date", "usd", "euro" | |
), row.names = c(NA, -128L), class = "data.frame") | |
y1 <- x$usd | |
y2 <- x$euro | |
plot(x$date, y1, type="l", col="blue", xlab="X axis label", ylab="Left legend") | |
par(new=TRUE) | |
plot(x$date, y2, type="l", ann=FALSE, yaxt="n", ) | |
title("Daily Canadian Dollars in USD and ERUO") | |
axis(4) | |
legend(x="topleft", bty="n", lty=c(1,1), col=c("blue","black"), legend=c("USD", "EURO")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment