3
$\begingroup$

I'm using Mathematica 13.3, I want to have a vector output image from all of my plots using hatch filling.

For a test code:

RegionPlot[Sin[x] Sin[y] > 1/4, {x, -10, 10}, {y, -10, 10},
 PlotStyle -> {RGBColor["#0077BB"], HatchFilling[]},
 BoundaryStyle -> Thickness[0.01]]

But the output ALWAYS contains bitmap fractures...clearly visible after zooming. How it can be solved with hatch filling.

enter image description here

$\endgroup$
1
  • $\begingroup$ I can see the very small "fractures" also in the documentation of HatchFilling. $\endgroup$
    – eldo
    Commented Oct 20, 2023 at 16:10

1 Answer 1

5
$\begingroup$
  • Export such drawing to pdf is not a vector format pdf file. We use Mesh to draw such hatchfilling instead.
plot = RegionPlot[Sin[x] Sin[y] > 1/4, {x, -10, 10}, {y, -10, 10}, 
  BoundaryStyle -> Thickness[0.01], PlotStyle -> None, Mesh -> 80, 
  MeshFunctions -> {#2 - #1 &}, 
  MeshStyle -> {RGBColor["#0077BB"], AbsoluteThickness[1.5]}]
Export["test.pdf", plot] // SystemOpen

enter image description here

enter image description here

  • For 20 Degree slope, since the equation of such lines are y=Tan[20 Degree] x +b ( where b is variety), so we can set MeshFunctions -> {#2 - Tan[20 Degree] #1 &} to change the angle of lines.
Clear[plot];
plot = 
 RegionPlot[Sin[x] Sin[y] > 1/4, {x, -10, 10}, {y, -10, 10}, 
  BoundaryStyle -> Thickness[0.01], PlotStyle -> None, Mesh -> 200, 
  MeshFunctions -> {#2 - Tan[20 Degree] #1 &}, 
  MeshStyle -> {RGBColor["#0077BB"], AbsoluteThickness[1]}];
Export["test.pdf", plot] // SystemOpen

enter image description here

$\endgroup$
2
  • $\begingroup$ Nice replacement of Hatching. One question related to usage of {#2 - #1 &}...The filling inside a region requires two things: Spacing between lines & angle of those lines. If you can suggest something in MeshFunction that can fulfil this. $\endgroup$ Commented Oct 22, 2023 at 1:05
  • $\begingroup$ Thanks^Infinity... $\endgroup$ Commented Oct 22, 2023 at 2:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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