Skip to main content

Following some of the questions here on StackExchangeMathematica Stack Exchange, I am trying to export an image that contains a rasterized object and vector-graphics axes.

Here is an example:

myArray = Table[{x, y, RandomReal[]}, {x, 0, 100}, {y, 0, 100}];

size = 500;

myImage = 
 ListDensityPlot[Flatten[myArray, 1], Mesh -> 20, 
  ColorFunction -> "AvocadoColors", PerformanceGoal -> "Quality", 
  FrameLabel -> {"\[Mu]", "C"}, FrameStyle -> Directive[14], 
  ImageSize -> size];

img = Rasterize[Show[myImage, Frame -> None], ImageResolution -> 100, 
   ImageSize -> size];

g = Graphics[
  Inset[img, Scaled[{0.5, 0.5}], {Center, Center}, size], 
  AbsoluteOptions[myImage]]

Here is the result::

enter image description here

You can notice, if you compare with the original image, that the scaling of the inserted object is not correct.

Now two my questions:

  1. How to figure out the size of the object that I insert automatically. Here, if I replace size with 0.21 size I will get a correct image. Why is 0.21?
  2. Why the size of ticks and numbering does not coincide with the original image and how to fix it?

Thank you.

Following some of the questions here on StackExchange, I am trying to export an image that contains a rasterized object and vector-graphics axes.

Here is an example:

myArray = Table[{x, y, RandomReal[]}, {x, 0, 100}, {y, 0, 100}];

size = 500;

myImage = 
 ListDensityPlot[Flatten[myArray, 1], Mesh -> 20, 
  ColorFunction -> "AvocadoColors", PerformanceGoal -> "Quality", 
  FrameLabel -> {"\[Mu]", "C"}, FrameStyle -> Directive[14], 
  ImageSize -> size];

img = Rasterize[Show[myImage, Frame -> None], ImageResolution -> 100, 
   ImageSize -> size];

g = Graphics[
  Inset[img, Scaled[{0.5, 0.5}], {Center, Center}, size], 
  AbsoluteOptions[myImage]]

Here is the result::

enter image description here

You can notice, if you compare with the original image, that the scaling of the inserted object is not correct.

Now two my questions:

  1. How to figure out the size of the object that I insert automatically. Here, if I replace size with 0.21 size I will get a correct image. Why is 0.21?
  2. Why the size of ticks and numbering does not coincide with the original image and how to fix it?

Thank you.

Following some of the questions here on Mathematica Stack Exchange, I am trying to export an image that contains a rasterized object and vector-graphics axes.

Here is an example:

myArray = Table[{x, y, RandomReal[]}, {x, 0, 100}, {y, 0, 100}];

size = 500;

myImage = 
 ListDensityPlot[Flatten[myArray, 1], Mesh -> 20, 
  ColorFunction -> "AvocadoColors", PerformanceGoal -> "Quality", 
  FrameLabel -> {"\[Mu]", "C"}, FrameStyle -> Directive[14], 
  ImageSize -> size];

img = Rasterize[Show[myImage, Frame -> None], ImageResolution -> 100, 
   ImageSize -> size];

g = Graphics[
  Inset[img, Scaled[{0.5, 0.5}], {Center, Center}, size], 
  AbsoluteOptions[myImage]]

Here is the result::

enter image description here

You can notice, if you compare with the original image, that the scaling of the inserted object is not correct.

Now two my questions:

  1. How to figure out the size of the object that I insert automatically. Here, if I replace size with 0.21 size I will get a correct image. Why is 0.21?
  2. Why the size of ticks and numbering does not coincide with the original image and how to fix it?
Source Link
Artem
  • 1k
  • 10
  • 20

Rasterized image together with vector-graphics axes

Following some of the questions here on StackExchange, I am trying to export an image that contains a rasterized object and vector-graphics axes.

Here is an example:

myArray = Table[{x, y, RandomReal[]}, {x, 0, 100}, {y, 0, 100}];

size = 500;

myImage = 
 ListDensityPlot[Flatten[myArray, 1], Mesh -> 20, 
  ColorFunction -> "AvocadoColors", PerformanceGoal -> "Quality", 
  FrameLabel -> {"\[Mu]", "C"}, FrameStyle -> Directive[14], 
  ImageSize -> size];

img = Rasterize[Show[myImage, Frame -> None], ImageResolution -> 100, 
   ImageSize -> size];

g = Graphics[
  Inset[img, Scaled[{0.5, 0.5}], {Center, Center}, size], 
  AbsoluteOptions[myImage]]

Here is the result::

enter image description here

You can notice, if you compare with the original image, that the scaling of the inserted object is not correct.

Now two my questions:

  1. How to figure out the size of the object that I insert automatically. Here, if I replace size with 0.21 size I will get a correct image. Why is 0.21?
  2. Why the size of ticks and numbering does not coincide with the original image and how to fix it?

Thank you.