1

我想通过使用 Gnuplot 来改变这个极坐标图,如下所示:

  1. 根据范围通过不同颜色更改线条颜色(径向线及其半圆形边缘)。例如,A到F间隔为红色,G到L为蓝色,M到S保持黑色

下面,我提供了我的代码,如果有人帮忙,我将不胜感激。

在此处输入图像描述

'设置小数'。'

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

set style line 10 lt rgb "black" lw 4.0 #redefine a new line style for the grid

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

set rrange [0:0.3]
set rtics 0, 0.05, 0.2 format "%.2f"

set size square 

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

#here all labels are created
eval set_label(0, "A")
eval set_label(20, "B")
eval set_label(40, "C")
eval set_label(60, "D")
eval set_label(80, "E")
eval set_label(100, "F")
eval set_label(120, "G")
eval set_label(140, "H")
eval set_label(160, "I")
eval set_label(180, "J")
eval set_label(200, "K")
eval set_label(220, "L")
eval set_label(240, "M")
eval set_label(260, "N")
eval set_label(280, "O")
eval set_label(300, "P")
eval set_label(320, "Q")
eval set_label(340, "S")


set style line 11 lt rgb "blue" lw 10 pt 6 ps 6

plot "-" u 1:2 w lp ls 11
0    0.1499
020   0.1517
040   0.1474
060   0.1520
080   0.1526
100  0.1501
120  0.1491
140  0.1530
160  0.1515
180  0.1519
200  0.1534
220  0.1509
240  0.1501
260  0.1520
280  0.1481
300  0.1523
320  0.1529
340  0.1505
360    0.1499`
4

1 回答 1

2

这是我的建议。您可以稍微缩短标签的放置时间。我不知道您可以为网格线设置单独的颜色,因此您必须“手动”为它们着色。检查下面的示例作为起点。我以为来了之后QR没有了S

代码:(编辑:添加了彩色边框)

### polar graph with colored grid lines
reset session

$Data <<EOD
0    0.1499
020   0.1517
040   0.1474
060   0.1520
080   0.1526
100  0.1501
120  0.1491
140  0.1530
160  0.1515
180  0.1519
200  0.1534
220  0.1509
240  0.1501
260  0.1520
280  0.1481
300  0.1523
320  0.1529
340  0.1505
360    0.1499
EOD

set size square 
unset border
set polar
set angles degrees
unset label
unset tics
unset key 

set style line 10 lt rgb "black" lw 1
set style line 11 lt rgb "blue" lw 4 pt 6 ps 1

set rrange [0:0.2]
set rtics 0, 0.05, 0.2 format "%.2f"

Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
N=18
set grid polar 360./N ls 10
set for [a=1:N] ttics (Alphabet[a:a] (a-1)*360./N)    # set ttic labels

R=0.2
myColors   = '0xff0000 0x00ffff 0x000000'
myColor(n) = word(myColors,(n-1)/(N/3)+1)   #  !!! integer division

set for [a= 1: N] object a circle at 0,0 size R arc [(a-1)*360./N:a*360./N] fc rgb myColor(a) lw 2 front wedge

plot $Data u 1:2 w lp ls 11
### end of code

结果:

在此处输入图像描述

于 2021-11-10T15:40:21.057 回答