具有颜色渐变的线图
Line plot with color gradient
有没有办法在 IDL 中创建带有颜色渐变的绘图?我要查找的内容类似于 。我知道的最好的方法是在 for
循环中绘制每一段线,但这看起来很麻烦:
x = float(indgen(11) - 5)
y = x ^ 2
loadct, 2, /silent
!p.background = 255
plot, x, y
for i = 0, 9 do begin
oplot, x(i:i+1), y(i:i+1), color = i * 20, thick = 4
endfor
我正在使用 IDL 8.2,如果有区别的话。
我曾经遇到过同样的问题,但似乎没有(简单的)解决方案。虽然我投降了,但您可以尝试使用由 PLOT function:
提供的 RGB 向量和 VERT_COLORS-keywords
A vector of indices into the color table for the color of each vertex
(plot data point). Alternately, a 3xN byte array containing vertex
color values. If the values supplied are not of type byte, they are
scaled to the byte range using BYTSCL. If indices are supplied but no
colors are provided with the RGB_TABLE property, a default grayscale
ramp is used. If a 3xN array of colors is provided, the colors are
used directly and the color values provided with RGB_TABLE are
ignored. If the number of indices or colors specified is less than the
number of vertices, the colors are repeated cyclically.
这会使外观变得更加独立,但也许会对您有所帮助。
我有一个例程 MG_PLOTS 可以在直接图形中执行此操作:
IDL> plot, x, y, /nodata, color=0, background=255
IDL> mg_plots, x, y, color=indgen(10) * 20, thick=4
当然,它只是您手动操作的包装器。
有没有办法在 IDL 中创建带有颜色渐变的绘图?我要查找的内容类似于 for
循环中绘制每一段线,但这看起来很麻烦:
x = float(indgen(11) - 5)
y = x ^ 2
loadct, 2, /silent
!p.background = 255
plot, x, y
for i = 0, 9 do begin
oplot, x(i:i+1), y(i:i+1), color = i * 20, thick = 4
endfor
我正在使用 IDL 8.2,如果有区别的话。
我曾经遇到过同样的问题,但似乎没有(简单的)解决方案。虽然我投降了,但您可以尝试使用由 PLOT function:
提供的 RGB 向量和 VERT_COLORS-keywordsA vector of indices into the color table for the color of each vertex (plot data point). Alternately, a 3xN byte array containing vertex color values. If the values supplied are not of type byte, they are scaled to the byte range using BYTSCL. If indices are supplied but no colors are provided with the RGB_TABLE property, a default grayscale ramp is used. If a 3xN array of colors is provided, the colors are used directly and the color values provided with RGB_TABLE are ignored. If the number of indices or colors specified is less than the number of vertices, the colors are repeated cyclically.
这会使外观变得更加独立,但也许会对您有所帮助。
我有一个例程 MG_PLOTS 可以在直接图形中执行此操作:
IDL> plot, x, y, /nodata, color=0, background=255
IDL> mg_plots, x, y, color=indgen(10) * 20, thick=4
当然,它只是您手动操作的包装器。