PrettyColorize for Mathematica figure preparation

This post was auto converted and may contain formatting errors.

PrettyColorize

Tools for customizing the colors of your figures in Mathematica. You can download it from GitHub.

Installation

  1. Install PrettyRandomColor following instructions here.
  2. Open the Mathematica user application folder by

    SystemOpen @ FileNameJoin[{$UserBaseDirectory, "Applications"}];

  3. Create a folder called /PrettyColorize and place PrettyColorize.wl and /Kernel inside.

Usage

  • Load package using << PrettyColorize`.
  • Apply PrettyColorize to any plotting function, e.g., Plot, ListPlot, Plot3D…

Code example

Minimal example

Wherever a color directive can be placed, you can instead put a Pretty[itemName_String] as a placeholder.

PrettyColorize @ Plot[x, {x, -5, 5}, PlotStyle -> Pretty["Line"]]

The above code generates a color palette shown below. Left-click on colors/storage changes the currently selected target item. Right-click on colors copies the clicked color to storage. Right-click on storage removes the clicked stored color.

Pressing Confirm button will generate a runnable cell that replace the Pretty placeholder to the selected colors:

ContourPlot

Update and upgrade the server

PrettyColorize @
 ContourPlot[{Abs[Sin[x] Sin[y]] == 0.5, Abs[Cos[x] Cos[y]] == 0.5}, {x, -3, 3}, {y, -3, 3},
  ContourStyle -> {{Pretty["Contour1"]}, {Pretty["Contour2"], Dashed}},
  FrameTicks -> None,
  Epilog -> {
      Pretty["Points"],
      PointSize[0.025],
      Point[{{0, 0}, {\[Pi]/2, \[Pi]/2}, {-\[Pi]/2, \[Pi]/2}, {\[Pi]/2, -\[Pi]/2}, {-\[Pi]/2, -\[Pi]/2}}]
    }
 ]

Plot3D

PrettyColorize @
 Plot3D[{x^2 + y^2, 100 Exp[-0.5 (x^2 + y^2)]}, {x, -5, 5}, {y, -5, 5},
  PlotRange -> All,
  PlotStyle -> {Pretty["Surface1"], Pretty["Surface2"]},
  Mesh -> None,
  BoxStyle -> Directive[Pretty["Box"]],
  AxesStyle -> Directive[Pretty["Box"]],
  Ticks -> None
 ]

A more ‘serious’ example

MaTeX developed by Szabolcs Horvát is recommended when drawing scientific figures in Mathematica.

<< MaTeX`

PrettyColorize @ Plot[
  {
   Callout[(2 x)^2 Sin[x],
    MaTeX @ {"Min", "Max"},
    {Below, Above},
    Background -> Pretty["Callout"],
    FrameMargins -> 2,
    Appearance -> "Balloon"
    ],
   -10 x
  },
  {x, -3, 3},
  PlotRange -> {-40, 40},
  PlotStyle -> {{Pretty["Curve1"]}, {Pretty["Curve2"]}},
  Frame -> True,
  FrameStyle -> Black,
  FrameTicks -> {
    {Thread[{#, MaTeX @ #}] & /@ Range[-40, 40, 20], None}, {Thread[{#, MaTeX @ #}] & /@ Range[-3, 3, 1], None}
  },
  AxesStyle -> Directive[Pretty["Axes"], Dashed],
  Filling -> {1 -> {{2}, {Pretty["FillLeft"], Pretty["FillRight"]}}},
  ImageSize -> 600
 ]

TODO

Known problems

  • Random functions will be called during every dynamic update.

Features

  • New colors generation based on existing stored colors.
  • A button for figure export.
  • Performance improvement on dynamic control objects.