Hi, I am trying to add a rectangle with a color gradient to a plot to indicate a special region that should fade out, i.e. have a color gradient to white. So far I have tried hpatch() and vpatch(), which give me the rectangle, but only in a solid color. I’ve managed to engineer a color gradient using a heatmap, but this overlays the xticks and yticks and is therefore not a suitable solution. I’ve tried to use fill, and then set the fill_z accordingly, but this gives me slices that do not interpolate nicely no matter how fine I make the spacing… here is some code to demonstrate what I try to achieve.
myCG = cgrad([:gray, :white]); gridSpacing = 50; xPatch = (1, 10); yPatch = (0, +1); x = range(xPatch, stop = xPatch, length = gridSpacing); y = yPatch * ones(length(x)); z = range(0, stop = 1, length = gridSpacing); myPlot = plot(x, y, linecolor = :transparent, fillrange = yPatch, fillcolor = myCG, fill_z = z, legend = false)
Is there any simple way to do this?