【问题标题】:How to plot arrows from angles of wind direction using vectors如何使用矢量从风向角度绘制箭头
【发布时间】:2019-12-30 04:58:39
【问题描述】:

我希望有人可以帮助我。我正在尝试绘制风的角度并为风的强度着色。风强度的调色板很好,但我无法将角度转换为矢量并正确绘制箭头 - 理想情况下没有“尾巴”/线.. 这是数据文件的示例:

"Date", "Temp", "icon", "rain", "snow", "wind.speed", "wind.deg", "clouds.all"
"2019-12-29 18:00:00",5.58,"04n",,,"n",2.45,185,51,1025
"2019-12-29 21:00:00",5.36,"04n",,,"n",2.51,182,99,1025
"2019-12-30 00:00:00",5.34,"04n",,,"n",2.6,196,95,1025
"2019-12-30 03:00:00",5.28,"03n",,,"n",2.72,207,47,1024
"2019-12-30 06:00:00",5.23,"02n",,,"n",2.62,200,23,1024
"2019-12-30 09:00:00",5.47,"01d",,,"d",2.48,214,0,1024
"2019-12-30 12:00:00",9.82,"01d",,,"d",3.96,215,0,1023
"2019-12-30 15:00:00",8.94,"01d",,,"d",3.24,218,0,1021
"2019-12-30 18:00:00",6.18,"01n",,,"n",2.88,214,0,1022
"2019-12-30 21:00:00",5.75,"01n",,,"n",2.13,232,0,1022
"2019-12-31 00:00:00",5.82,"03n",,,"n",0.8,216,33,1022
"2019-12-31 03:00:00",5.18,"04n",,,"n",0.32,8,66,1022
"2019-12-31 06:00:00",5.37,"04n",,,"n",1.79,58,83,1022
"2019-12-31 09:00:00",5.1,"04d",,,"d",3.88,66,100,1023
"2019-12-31 12:00:00",7.97,"04d",,,"d",4.39,84,100,1025
"2019-12-31 15:00:00",8.52,"04d",,,"d",3.97,74,100,1025
"2019-12-31 18:00:00",7.83,"04n",,,"n",2.97,58,100,1026
"2019-12-31 21:00:00",7.93,"04n",,,"n",4.08,72,100,1027

这是我到目前为止的代码 - 大部分来自这里:http://www.gnuplotting.org/vector-field-from-data-file/

#!/usr/bin/gnuplot
reset

set datafile missing "?"
set datafile separator ","

set terminal pngcairo true transparent truecolor size 1800, 500
set output '~/meteogram/vector.png'

set xdata time
set timefmt "%Y-%m-%d %H:%M:%S"

set palette defined ( 0 '#ffffff', \
1 '#ffee00',\
2 '#ff7000',\
3 '#ee0000',\
4 '#7f0000')

xf(phi) = 10*cos(phi/180.0*pi+pi/2)
yf(phi) = 10*sin(phi/180.0*pi+pi/2)

plot FILE every 1 using 1:($7-yf($8)):(2*xf($8)):(2*yf($8)):7 with vectors head fixed filled lc palette

我正在尝试从网站上获取类似这张图片的情节 所以只是一个箭头旋转以指示风的方向(按强度着色)但绘制在相同的 y 值 我应该补充一点,我在 Ubuntu 上使用 Gnuplot 5.2

【问题讨论】:

  • 抱歉,我不是 gnuplot 专家,但我用过的其他软件理解“零长度”尾部的概念。也许这里有这样的事情?如果您能说明所需的输出与电流输出,那也很好。祝你好运。

标签: gnuplot


【解决方案1】:
 set datafile missing "?"
 set datafile separator ","
 set xdata time
 set timefmt "%Y-%m-%d %H:%M:%S"
 set ang deg
 unset key
 unset colorbox

 plot 'wind.dat' using 1:7:("➤"):8:7 with labels rotate variable textcolor palette

此示例使用 unicode 字形 U+27A4“BLACK RIGHTWARDS ARROWHEAD”。其他可能的字符:→??????

精确的外观取决于字体和字体大小。

【讨论】:

  • 谢谢@ethan——太好了。我想知道标签,但不认为它会起作用。非常感谢您及时准确的回复!
  • 只是为其他感兴趣的人完成这个。风向以 0° 的角度给出,因此我使用指向下方“⮟”的 unicode 字形并反转旋转方向 - 使用 1:7:("⮟"):(0-$8):7
猜你喜欢
  • 1970-01-01
  • 2020-12-06
  • 2020-06-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-08-29
相关资源
最近更新 更多