Я бы хотел построить график зависимости скорости ветра от высоты. Я смог сделать это, используя матричный график, однако теперь, когда я пытаюсь сделать свои метки yaxis более стандартизированными (0,100,200,300 метров ... et c), но не знаю, как в настоящее время индексы для Yaxis (0: 200) согласовать с фактическими высотами.
Любые идеи изменить этот код или другой тип графика приветствуются.
данные можно скачать здесь: https://docs.google.com/spreadsheets/d/e/2PACX-1vSdYIBHyvv0ue1YMqXVUqVSeUyYbZH4fl-XhXe_tVa42iJsTGejeGX1re06-jL-kYiuIJCUohdvEL7k/pub?output=csv
РЕДАКТИРОВАТЬ: объяснение файла данных:
размеры данных 715 столбцов и 200 строк не включая заголовок Заголовок показывает время, в то время как вектор высоты (длина 200) соответствует строкам.
токовый выход: ![enter image description here](https://i.stack.imgur.com/NrRaw.png)
Пересмотрел код, чтобы убедиться, что он работает. Извинения за репост:
код:
wind_speeds <- data
altitudes <- c(1,29,58,87,116,145,174,203,232,261,290,319,348,377,406,435,464,493,522,551,580,609,638,667,696,725,
754,783,812,841,870,899,928,957,986,1015,1044,1073,1102,1131,1160,1189,1218,1247,1276,1305,1333,1362,
1391,1420,1449,1478,1507,1536,1565,1594,1623,1652,1681,1710,1739,1768,1797,1826,1855,1884,1913,1942,
1971,2000,2029,2058,2087,2116,2145,2174,2203,2232,2261,2290,2319,2348,2377,2406,2435,2464,2493,2522,
2551,2580,2609,2637,2666,2695,2724,2753,2782,2811,2840,2869,2898,2927,2956,2985,3014,3043,3072,3101,
3130,3159,3188,3217,3246,3275,3304,3333,3362,3391,3420,3449,3478,3507,3536,3565,3594,3623,3652,3681,
3710,3739,3768,3797,3826,3855,3884,3913,3941,3970,3999,4028,4057,4086,4115,4144,4173,4202,4231,4260,
4289,4318,4347,4376,4405,4434,4463,4492,4521,4550,4579,4608,4637,4666,4695,4724,4753,4782,4811,4840,
4869,4898,4927,4956,4985,5014,5043,5072,5101,5130,5159,5188,5217,5245,5274,5303,5332,5361,5390,5419,
5448,5477,5506,5535,5564,5593,5622,5651,5680,5709,5738,5767)
unique_hrs <- c("01", "02", "03", "04", "05", "06" ,"07", "08", "09" ,"10", "11", "12", "13", "14" ,"15" ,"16", "17" ,"18", "19", "20" ,"21" ,"22", "23")
unique_hrs_index <- c(16, 46, 76, 106, 135, 165, 195, 225, 255, 285, 314, 344, 374, 404, 433, 463, 493, 523, 553, 583, 612, 642, 672)
min <- 0
max <- 12
library(viridis)
ColorRamp <- viridis(n = (max*2))
ColorLevels <- seq(min, max, length=length(ColorRamp))
# Set layout. We are going to include a colorbar next to plot.
layout(matrix(data=c(1,2), nrow=1, ncol=2), widths=c(4,1),
heights=c(1,1))
#plotting margins. These seem to work well for me.
par(mar = c(4,5,4,2), font = 2)
# Plot it up!
image(1:ncol(wind_speeds), 1:nrow(wind_speeds), t(wind_speeds),
col=ColorRamp, xlab="Time (UTC)", ylab="Altitude (m)",
axes=FALSE, zlim=c(min,max), ylim = c(0,55),
main= NA)
#annotate the plot
box()
axis(side = 1, at=unique_hrs_index, labels=unique_hrs,
cex.axis=1.0)
axis(side = 2, at=seq(1,length(altitudes),1), labels=round(altitudes), las= 1,
cex.axis=1)
# Add colorbar to second plot region
par(mar = c(3,4,4,2))
image(1, ColorLevels,
matrix(data=ColorLevels, ncol=length(ColorLevels),nrow=1),
col=ColorRamp,xlab="",ylab="Wind Speed m/s",xaxt="n", las = 1)