4

I made a map in QGIS that includes a couple different gradients. Here you can see an indicator map that has a gradient fill enabled. (This image is from the print layout/composer.)

enter image description here

(Here is the symbology for the indicator map.) enter image description here

The gradient fill on the indicator map appears in the layout, however when I export the layout as an image they disappear.

Here is the map exported as a PNG. The box showing the extents of the main map also has a gradient fill, which is showing up, but the gradient fill on the continents is not visible. enter image description here

Here is the map exported as a JPEG. Again, not the result I was hoping for.
enter image description here

When I export to PDF the gradient is preserved, but looks different. As far as I can tell the rest of the map is exporting normally. enter image description here

What do I need to do to preserve the gradient fill on export? Is this the QGIS manifestation of this issue?

Update: The issue seems to be that the gradient fill being lost on export to image. I changed the color of the gradient from the old white-to-transparent gradient to one that is green to transparent. Here it is in the main QGIS window: enter image description here

And here it is in the print composer:

enter image description here

When I check the exported image (png) I still get the flat white appearance I showed above. Not even a hint of green. Somehow QGIS seems to be ignoring the fill when it exports.

enter image description here

My best guess at the moment is that it has something to do with the gradient fill's coord mode being set to viewport. If I set coord mode to object, the gradient fill in the print layout looks the same as the exported image. The question now becomes how to export a gradient fill with the coord mode set to viewport.

1

After a lot of trial and error, I believe the export issue is related to how QGIS calculates the gradient when the coord mode is set to viewport. To eliminate any interference from the underlying map, I created another layout in the print composer with just the indicator map on a blank background.

When the map is sized small, the above issue persists. On export the map appears washed out and the gradient is not visible.

enter image description here

When I increased the size to take up nearly the entire canvas however, the gradient was visible.

enter image description here

I believe what is happening here is likely that for the purposes of exporting the map, QGIS considers the entire canvas as the viewport for the gradient fill, and since the map is in the corner, all of the features are placed in the same semi-transparent area of the gradient. In the print composer meanwhile, I believe QGIS is calculating the gradient based on the frame of the indicator map, so the gradient is distributed correctly. I may be wrong about this, but this seems to explain the behavior I'm seeing.

Ultimately I fixed the problem by employing a workaround. I expanded frame of the indicator map to fill the entire canvas.

enter image description here

Then, I changed the color ramp to drop off quickly at the edges.

enter image description here

This then results in the desired gradient when I export the map to PNG or SVG. This doesn't 100% solve the original problem of exporting the gradient as it appeared in the print composer, but it is a reasonable approximation since my goal was just to have a semi-transparent indicator map with a gradient.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.