Rasterized density plot + countour plot in Mathematica (to solve EPS issues)

In summary: Your Name]In summary, the conversation is about a forum member seeking solutions for creating a smooth and visually appealing plot by combining a density plot and a contour plot, but running into issues with artifacts and file size when working with large data sets. Suggestions include increasing the number of plot points for a smoother representation and decreasing the resolution when exporting to decrease file size. Alternately, using the Overlay function to combine the plots may also help preserve their individual formats.
  • #1
abonatto
14
0
Dear All,

I am plotting a density and a contour plot of the same function in order to have a smooth shading in the background of the contour lines. I do this using "Show[DensityPlot[...], ContourPlot[..., ContourShading->None]", like the following example given by Mathematica help files:

Show[DensityPlot[Sin[x] Sin[y], {x, -3, 3}, {y, -3, 3}],
ContourPlot[Sin[x] Sin[y], {x, -3, 3}, {y, -3, 3},
ContourShading -> None]]

The problem is that, when I do this procedure to plot large lists of imported data, there are 2 big issues:

1st) there are some artifacts in the shading (like irregular grids of white lines).

2nd) if I export this as an EPS, the size of the generated file is huge!

As a solution I was thinking of rasterize the density plot (without frame, to have just the color gradient as a bitmap) and show it together with the contour plot (this way, all the contour lines and frame fonts would preserve their vectorial format). I have tried the following command:

Show[Rasterize[DensityPlot[...]], ContourPlot[..., ContourShading->None]

But it is not working. Any suggestions?

Regards.
 
Physics news on Phys.org
  • #2

Thank you for sharing your issue with us. It sounds like you are trying to create a smooth and visually appealing plot by combining a density plot and a contour plot, but are running into some issues with artifacts and file size when working with large data sets.

One potential solution to your first issue of artifacts in the shading could be to increase the number of plot points in your density plot. This can be done by specifying a higher value for the "PlotPoints" option in the DensityPlot function. This should result in a smoother and more accurate representation of your data.

For your second issue of large file size when exporting as EPS, you could try decreasing the resolution of the exported image. This can be done by specifying a lower value for the "ImageResolution" option in the Export function. This may result in a lower quality image, but it should also decrease the file size.

Another potential solution, as you mentioned, could be to rasterize the density plot and combine it with the vector contour plot. However, instead of using the Show function, you could try using the Overlay function to combine the two plots. This function allows for the combination of multiple plots while preserving their individual formats.

I hope these suggestions are helpful in solving your issues. If you continue to experience problems, please don't hesitate to reach out for further assistance.
 

1. What is a rasterized density plot and contour plot?

A rasterized density plot is a visualization method used to show the distribution of data points in a continuous manner. It is created by dividing the data into a grid and coloring each grid cell based on the number of data points within that cell. A contour plot is a type of graph that represents the shape and density of a continuous function. It is created by drawing lines that connect points of equal value on a 2D graph.

2. Why is rasterization important for EPS issues in Mathematica?

EPS (Encapsulated PostScript) is a file format commonly used for vector graphics, including plots and diagrams. When exporting a plot from Mathematica to EPS, the file can become very large and difficult to handle. Rasterization is important in this case because it converts the plot into a bitmap image, significantly reducing the file size and solving any EPS issues.

3. How do you create a rasterized density plot + contour plot in Mathematica?

To create a rasterized density plot + contour plot in Mathematica, you can use the Rasterize function. This function allows you to specify the resolution and format of the rasterized plot. You can also use the ContourPlot function to create the contour plot and then use Show to combine it with the rasterized density plot.

4. Can you customize the appearance of a rasterized density plot + contour plot in Mathematica?

Yes, you can customize the appearance of a rasterized density plot + contour plot in Mathematica by using various options and parameters available in the ContourPlot function. For example, you can change the color scheme, add labels and legends, and adjust the contour levels to better represent the data.

5. Are there any limitations to using rasterized density plots + contour plots in Mathematica?

One limitation of using rasterized density plots + contour plots in Mathematica is that it may not accurately represent the underlying data if the grid size is too large or too small. Additionally, the resolution of the rasterized plot may affect the level of detail and clarity in the final image. It is important to carefully choose the appropriate grid size and resolution for each specific dataset.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
885
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
731
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • Programming and Computer Science
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
Back
Top