Merge key entries in gnuplot

前端 未结 2 452
广开言路
广开言路 2020-12-22 06:08

I would like to plot data with lines and points with different colors. It seems to exist different solutions:

  • https://stackoverflow.com/a/31887351/4373898 , ht
2条回答
  •  -上瘾入骨i
    2020-12-22 06:25

    If your plot is not too complex, you could perhaps achieve this by playing with the spacing parameter of the legend. Setting spacing to -1 achieves that the labels/symbols overlap:

    set terminal pngcairo enhanced
    set output 'fig.png'
    
    set xr [-pi/2:pi/2]
    set yr [0:1]
    
    set key at graph 0.95,graph 0.9 spacing -1
    
    plot \
        cos(x) w l lc rgb 'dark-red' lw 2, \
        '-' w p lc rgb 'royalblue' pt 7 ps 2 t ' '
    -1  0.540302
    0   1
    1   0.540302
    e
    

    which gives

    However, the disadvantage is that the setting is in a sense global - should the plot contain more functions/data files, everything would overlap. In order to use this "method" in this particular case, it would be necessary to invoke multiplot and create the keys separately.

提交回复
热议问题