【问题标题】:How to get a radial(polar) plot using gnu plot?如何使用 gnuplot 获得径向(极坐标)图?
【发布时间】:2011-07-21 06:32:06
【问题描述】:

我想要一个使用 gnuplot 的径向(极坐标)图(即在圆形坐标系中(r,theta)。

这里我使用了值:

Theta Max-strain
0     3400
60    5300
120   4700
180   3800
240   4100
300   3100
360   3400

如何使用 gnu-plot 得到这样的情节?

【问题讨论】:

  • 您可能希望摆脱情节中的 360°,因为它与 0° 是多余的......

标签: gnuplot


【解决方案1】:

我试图重新创建你的问题的情节,这就是我想出的:

unset border
set polar
set angles degrees #set gnuplot on degrees instead of radians

set style line 10 lt 1 lc 0 lw 0.3 #redefine a new line style for the grid

set grid polar 60 #set the grid to be displayed every 60 degrees
set grid ls 10

set xrange [-6000:6000] #make gnuplot to go until 6000
set yrange [-6000:6000]

set xtics axis #disply the xtics on the axis instead of on the border
set ytics axis

set xtics scale 0 #"remove" the tics so that only the y tics are displayed
set xtics ("" 1000, "" 2000, "" 3000, "" 4000, "" 5000, "" 6000) #set the xtics only go from 0 to 6000 with increment of1000 but do not display anything. This has to be done otherwise the grid will not be displayed correctly.
set ytics 0, 1000, 6000 #make the ytics go from the center (0) to 6000 with incrment of 1000

set size square 

set key lmargin

set_label(x, text) = sprintf("set label '%s' at (6500*cos(%f)), (6500*sin(%f))     center", text, x, x) #this places a label on the outside

#here all labels are created
eval set_label(0, "0")
eval set_label(60, "60")
eval set_label(120, "120")
eval set_label(180, "180")
eval set_label(240, "240")
eval set_label(300, "300")


set style line 11 lt 1 lw 2 pt 2 ps 2 #set the line style for the plot

#and finally the plot
plot "-" u 1:2 t "Max strain" w lp ls 11
0 3400
60 5300
120 4700
180 3800
240 4100
300 3100
360 3400
e

如您所见,主要区别在于角度 0 不在顶部而是在右侧(这在数学上是正确的)。但是,您可以通过修改绘图中的 using deceleration 和 set_label 函数来更改此设置。

正如您在脚本中看到的那样,并非所有内容都非常清晰和闪亮。如果有人发现改进,请告诉我!

最后一点“建议”:尝试使用 gnuplot 从某个工具重现绘图并不总是合理的。通常,gnuplot 的优势在于以最简单的方式绘制数据,以便于重现。也许您可以从上面的脚本中剔除一些行,并且仍然对它感到满意。

【讨论】:

  • 非常感谢。这很有帮助。我尝试完全按照您上面提到的方式使用 set_label,但出现错误。没有标签它工作正常。此外,如果有负值说 -3400、-5300 等……那么在上面的图中,y 轴上不是 6000 到 0,它应该是 0 到 -6000 向内。类似于您在 MS Excel 中获得的图。如何得到这样的情节?
  • @Dolly set_label 宏正在我的机器上运行。错误信息是什么?至于负值:在极坐标图中,您不能有负值,因为该值或多或少是一个半径,而半径不能为负。如果你有负值,也许你不应该使用极坐标图或者用explog映射它?!
  • 当我使用 set_label 时,情节没有被创建。当我不使用 set_label 时,会创建绘图。该选项在较旧的 gnu-plot 版本中不可用吗?我在哪里可以下载新版本?
  • @Dolly 我不知道你必须拥有什么版本的 gnuplot 才能使宏工作。但拥有最新版本总是一个好主意。您可以从here 获取它们。
  • @Dolly 将 "-" 替换为值所在的文件名。类似于:plot "Data.dat" u 1:2 ...
【解决方案2】:

这是一本手册http://t16web.lanl.gov/Kawano/gnuplot/polar-e.html

 set polar
 set angles degrees

并获得圈子:

 set grid polar

这是一个演示:http://gnuplot.sourceforge.net/demo/polar.html

【讨论】:

  • 谢谢。我已经尝试过使用设置网格极坐标。但我无法显示其中的角度,我必须指定 x 和 y,并且获得的图与我想要的不匹配。我现在重新提出了我的问题。希望这次我清楚了。
  • 尝试做plot data ... with lines
  • set grid polar 30 将添加每 30 度线的网格。
猜你喜欢
  • 2020-10-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-08-22
  • 1970-01-01
  • 2022-10-13
  • 2010-09-18
  • 1970-01-01
相关资源
最近更新 更多