0
$\begingroup$

Let's create a custom color bar

Clear["Global`*"];

type1a = Graphics[{Green, Rectangle[{2, 1}, {4, 2}], Text[Style["Type 1a", Black, FontFamily -> "Helvetica", 20], {3, 
  1.5}]}];
type1b = Graphics[{Darker[Green], Rectangle[{2, 1}, {4, 2}],Text[Style["Type 1b", Black, FontFamily -> "Helvetica", 20], {3, 
  1.5}]}];
type2a = Graphics[{RGBColor[128/255, 128/255, 0], Rectangle[{2, 1}, {4, 2}], 
Text[Style["Type 2a", Black, FontFamily -> "Helvetica", 20], {3, 
  1.5}]}];
type2b = Graphics[{Orange, Rectangle[{2, 1}, {4, 2}], Text[Style["Type 2b", Black, FontFamily -> "Helvetica", 20], {3, 
  1.5}]}];
type3a = Graphics[{Magenta, Rectangle[{2, 1}, {4, 2}], Text[Style["Type 3a", Black, FontFamily -> "Helvetica", 20], {3, 
  1.5}]}];
type3b = Graphics[{Pink, Rectangle[{2, 1}, {4, 2}], Text[Style["Type 3b", Black, FontFamily -> "Helvetica", 20], {3, 
  1.5}]}];
type99 = Graphics[{Brown, Rectangle[{2, 1}, {4, 2}], Text[Style["Other", Black, FontFamily -> "Helvetica", 20], {3, 
  1.5}]}];
esc = Graphics[{Cyan, Rectangle[{2, 1}, {4, 2}], Text[Style["Escaping", Black, FontFamily -> "Helvetica", 20], {3, 
  1.5}]}];
cra1 = Graphics[{Blue, Rectangle[{2, 1}, {4, 2}], Text[Style["Collision 1", White, FontFamily -> "Helvetica", 
  17], {3, 1.5}]}];
cra2 = Graphics[{Red, Rectangle[{2, 1}, {4, 2}], Text[Style["Collision 2", Black, FontFamily -> "Helvetica", 
  17], {3, 1.5}]}];
cha = Graphics[{Yellow, Rectangle[{2, 1}, {4, 2}], Text[Style["Chaotic", Black, FontFamily -> "Helvetica", 20], {3, 
  1.5}]}];

colbar = Row[{esc, cra1, cra2, type1a, type1b, type2a, type2b, type3a, type3b, cha, type99}]

Then I want to export it as a JPEG file with at least 500 dpi resolution.

E0 = Export["colorbar.jpg", colbar, ImageResolution -> 500];

However I get the following output

enter image description here

As you can see, the row breaks into two columns. Why? Is there a way to correctly export the row with the desired resolution?

EDIT:

I found a solution by simply manipulating the size of the row as

colbar = Row[{esc, col1, col2, type1a, type1b, type2a, type2b, type3a,
type3b, cha, type99}, ImageSize -> {1000, 50}]

Then I can export the row with the desired resolution.

$\endgroup$
1
$\begingroup$

Perhaps instead of Row, use ImageAssemble:

Export["colorbar.jpg", 
 ImageAssemble[{esc, cra1, cra2, type1a, type1b, type2a, type2b, type3a, type3b, cha, type99}], 
 ImageResolution -> 500]

enter image description here

Since the text is small due to some detail of the rasterization, we will want to increase the font size.

type1a = Graphics[{Green, Rectangle[{2, 1}, {4, 2}], 
    Text[Style["Type 1a", Black, FontFamily -> "Helvetica", 80], {3, 
      1.5}]}];
type1b = Graphics[{Darker[Green], Rectangle[{2, 1}, {4, 2}], 
    Text[Style["Type 1b", Black, FontFamily -> "Helvetica", 80], {3, 
      1.5}]}];
type2a = Graphics[{RGBColor[128/255, 128/255, 0], 
    Rectangle[{2, 1}, {4, 2}], 
    Text[Style["Type 2a", Black, FontFamily -> "Helvetica", 80], {3, 
      1.5}]}];
type2b = Graphics[{Orange, Rectangle[{2, 1}, {4, 2}], 
    Text[Style["Type 2b", Black, FontFamily -> "Helvetica", 80], {3, 
      1.5}]}];
type3a = Graphics[{Magenta, Rectangle[{2, 1}, {4, 2}], 
    Text[Style["Type 3a", Black, FontFamily -> "Helvetica", 80], {3, 
      1.5}]}];
type3b = Graphics[{Pink, Rectangle[{2, 1}, {4, 2}], 
    Text[Style["Type 3b", Black, FontFamily -> "Helvetica", 80], {3, 
      1.5}]}];
type99 = Graphics[{Brown, Rectangle[{2, 1}, {4, 2}], 
    Text[Style["Other", Black, FontFamily -> "Helvetica", 80], {3, 
      1.5}]}];
esc = Graphics[{Cyan, Rectangle[{2, 1}, {4, 2}], 
    Text[Style["Escaping", Black, FontFamily -> "Helvetica", 80], {3, 
      1.5}]}];
cra1 = Graphics[{Blue, Rectangle[{2, 1}, {4, 2}], 
    Text[Style["Collision 1", White, FontFamily -> "Helvetica", 
      70], {3, 1.5}]}];
cra2 = Graphics[{Red, Rectangle[{2, 1}, {4, 2}], 
    Text[Style["Collision 2", Black, FontFamily -> "Helvetica", 
      70], {3, 1.5}]}];
cha = Graphics[{Yellow, Rectangle[{2, 1}, {4, 2}], 
    Text[Style["Chaotic", Black, FontFamily -> "Helvetica", 80], {3, 
      1.5}]}];

Export["colorbar.jpg", 
 ImageAssemble[{esc, cra1, cra2, type1a, type1b, type2a, type2b, type3a, type3b, cha, type99}], 
 ImageResolution -> 500]

enter image description here

$\endgroup$
  • $\begingroup$ Unfortunately, the text is also unreadable in my OS. $\endgroup$ – Vaggelis_Z Jan 27 at 10:44
  • $\begingroup$ It seems that simply upping the font size will fix this issue. $\endgroup$ – Carl Lange Jan 27 at 10:45
  • $\begingroup$ This is a hack! There must be a way to use Row and Export correctly. $\endgroup$ – Vaggelis_Z Jan 27 at 10:48
  • $\begingroup$ @Vaggelis_Z I do not believe that using Row is the correct solution to this problem. Row is best used for displaying items inside your notebook while ImageAssemble is purpose built to catenate images. $\endgroup$ – Carl Lange Jan 27 at 10:51
  • $\begingroup$ I found a solution! See my edit! $\endgroup$ – Vaggelis_Z Jan 27 at 10:51
1
$\begingroup$

Try Grid instead.

colbar = Grid[{{esc, cra1, cra2, type1a, type1b, type2a, type2b, 
    type3a, type3b, cha, type99}}, ItemSize -> Full]
$\endgroup$

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.