Hot answers tagged

57

In this answer, I will concentrate on the colors only to create something like this Copying the colors from python is a very fast way to get similar results. Nevertheless, the best way to understand what's happening is still to read the underlying publication that was used in seaborn: A colour scheme for the display of astronomical intensity images There, ...


39

Styling closer to your example, using The Toad's colors: colors = {RGBColor[{0.9312692223325372, 0.8201921796082118, 0.7971480974663592}], RGBColor[{0.8822898168737189, 0.695820866705742, 0.7065457119485431}], RGBColor[{0.8135380254700676, 0.5705055182357822, 0.639280859468155}], RGBColor[{0.7195800708349119, 0.45537982893127477`, 0....


38

Using color functions efficiently in data visualizations is more of an art than a recipe, so don't worry if you're not "good" at it yet. It's only a matter of time :) Copying the color schemes from seaborn: The best way to mimic those color schemes in Mathematica would be to copy the RGB values from seaborn for your preferred color scheme. You can find ...


31

First define the Morse code (from rosettacode.org with corrections by @evanb) morsecode = (#1 -> Characters[#2]) & @@@ { {"a", ".-"}, {"b", "-..."}, {"c", "-.-."}, {"d", "-.."}, {"e", "."}, {"f", "..-."}, {"g", "--."}, {"h", "...."}, {"i", ".."}, {"j", ".---"}, {"k", "-.-"}, {"l", ".-.."}, {"m", "--"}, {"n", "-."}, {"o", "---"}, {"p"...


29

Reproduced in v.10.0.0 under Win7 x64. In versions 8.0.4 and 9.0.1 the behavior differs in details but the bug is also present: only major logarithmic frame ticks change their thickness, but not minor ticks. Let us elaborate. First of all, in v.10 the logarithmic tick specifications are generated dynamically when the plot is rendered by the FrontEnd by ...


24

For most strings you can use simply: ToString[string] Or more rigorously: ToString[string, OutputForm] Observe: If your styled string includes two dimensional formatting that you do not wish to change you will find OutputForm unacceptable. Of course the 2D formatting itself will mean that the string cannot be in a "plain" form, but we can still strip ...


17

Here is what I was suggesting in comments: SeedRandom[] relaxed = Nest[ PropertyValue[{VoronoiMesh[#, {{-1, 1}, {-1, 1}}], {2, All}}, MeshCellCentroid] &, RandomReal[{-1, 1}, {45, 2}], 500 ]; mesh = VoronoiMesh[relaxed, {{-1, 1}, {-1, 1}}, MeshCellStyle -> {1 -> White}]; Then extract the cell primitives corresponding to the interior ...


16

Though I was expecting to need something fancy I stumbled upon a simple solution: ListLinePlot[data, PlotMarkers -> Graphics[{Disk[]}, ImageSize -> 13], PlotLegends -> Automatic ] The only change is enclosing Disk[] in { }. Looking at the InputForm we see that expressions involving Disk have been changed to e.g.: Graphics[{ Hue[0.67, 0.6,...


16

One can use Prolog to create a background for a Plot. Plot[Sin[x], {x, 0, 2 Pi}, PlotStyle -> Red, Prolog -> Inset[RandomImage[UniformDistribution[{.2, .6}], ColorSpace -> "Grayscale", ImageSize -> Full]], PlotRangeClipping -> False, AxesStyle -> White]


15

Hunting through the stylesheets is effective, but does not necessarily give you the current value being used if it has been modified. Instead, use CurrentValue[{StyleDefinitions , "GraphicsAxes"}] (* {Arrowheads -> {}, LineColor -> GrayLevel[0.4], Thickness -> Absolute[0.2]} *) CurrentValue[{StyleDefinitions , "GraphicsFrame"}] (* {LineColor -> ...


14

This required editing the cell expression (Ctrl+Shift+E, or Cmd+Shift+E on Mac), but it's exactly what you're looking for: Cell[StyleData["childstylename", StyleDefinitions-> StyleData["parentstylename"]], opts...] To do this, your stylesheet has to either contain the parent style or inherit from another stylesheet which contains the parent style. ...


14

If you inspect the InputForm of the "ColorFunction" property for "AvocadoColors" you see that it uses Blend with a list of colors: ColorData["AvocadoColors", "ColorFunction"] // InputForm ColorDataFunction["AvocadoColors", "Gradients", {0, 1}, Blend["AvocadoColors", #1] &] Similarly, ...


14

1 + 4 We can discretize the rounded Polygon objects and then add the negative of the mesh through Prolog. rm = DiscretizeGraphics[roundedPolygon[#, 0.3] & /@ MeshPrimitives[mesh, 2]] Now there's some floating point differences in the results from roundedPolygon that seem to effect subsequent Boolean operations. We can fix this crudely merging nearby ...


13

Update 3: With the new-in-version-12.1 function EdgeTaggedGraph we can style and label edges individually in multi-graphs: labels = {"A", "B", "C", "D", "E", "F"}; edges = {a -> b, a -> b, a -> b, a -> b, a -> e, e -> b}; styles = {Red, Directive[Dashed, Blue], Orange, Directive[Purple, Dashing[.01]], Green, Green}; labelededges = ...


13

Why not just use the graphic in the question, or any other images that you like: Use ImageSize to control the final size of the button: An alternative, that I use in some applications, is something like this: help[$helpmessage_: "", $videolink_: ""] := ActionMenu[ Graphics[{{RGBColor[0.689647, 0.761166, 0.805478], Disk[{0, 0}, 0.1]}, {...


12

MeshShading Plot[Sin[x], {x, 0, 2 Pi}, MeshFunctions -> {# &}, Mesh -> {{Pi/2}}, MeshShading -> {Red, Directive[Dashed, Blue]}, PlotStyle -> Thick] Two piecewise functions Plot[{ConditionalExpression[Sin[x], x <= Pi], ConditionalExpression[Sin[x], x >= Pi]}, {x, 0, 2 Pi}, PlotStyle -> {Directive[Thick, Red], Directive[...


12

In Graphics and Graphics3D Style behaves mostly as a grouping construct like List. You can use List (instead) for most things, even Options like FontSize or Antialiasing Graphics3D[{FontSize -> 40, Text["sample"]}] Graphics[{Circle[{0, 0}, 1], {Antialiasing -> False, Circle[{0, 0}, 0.8]}}] There are however directives that only work in Style, e.g. ...


12

Unfortunately, I don't know how to completely fix that plotting artifact at "z" axis. z = (2 x^2 y)/(x^4 + y^2); Plot3D[z, {x, 0, 1}, {y, 0, 1}, PerformanceGoal -> "Quality", PlotPoints -> 100, MaxRecursion -> 4, Boxed -> False, AxesLabel -> {"x", "y", "z"}, AspectRatio -> 1, Ticks -> None, AxesEdge -> {{-1, -1}, {-1, -1}, {-...


12

If you are not completely attached to Voronoi, you might consider tiling with hexagons and then perturbing their coordinates. GraphicsComplex makes it work. Define a hexagon. HexTile[s_] := Polygon[s*{{Sqrt[3], 1}/2, {0, 1}, {-Sqrt[3], 1}/2, {-Sqrt[3], -1}/2, {0, -1}, {Sqrt[3], -1}/2}] Allow for translation. TranslateObject[p_, {...


11

The circle is not cropped when used in a Subscript: Subscript["M", "⊙"] Thus, by using this answer you can easily do: str = "This is some text with a CircleDot: " <> ToString[Subscript["M", "⊙"], FormatType -> StandardForm] If you want some Style: Style[str, Red, 20]


11

I believe you want "FrontFaceColor" which can be found as a specification in this list: Graphics[{FaceForm[RGBColor[2/3, 1/3, 2/3]], EdgeForm[Black], Dynamic[{If[CurrentValue["MouseOver"], Darker @ CurrentValue["FrontFaceColor"]], Disk[]}]}] You may also find "FrontFaceOpacity" of use. Simply guessing I found that "BackFaceColor" is also valid, e....


11

There is another way that is on my machine almost 500x faster then your solution. The idea is to look how Mathematica represents colored strings and use this directly. When we colorize an input string by selecting text and using the Format menu, we can create something like this Now, press Ctrl+Shift+E to see the underlying expression. Cell[BoxData["\"...


11

Update: Better mesh grid This code, while using the parametrization in my original answer that removes the glitch at the z-axis, better reproduces the mesh in the OP's figure. One problem all the other solutions (so far) suffer from is that the linear elements (mesh lines) and surfaces elements do not interact well in rendering: You can see mesh lines poke ...


11

Try the following: (if you don't understand what an option does, leave a comment - but please look in the documentation center first) addCallout[min_, max_, date_, val_, Left] := {Line@{{min, val}, {date, val}}, Text[Pane[Round@val, FrameMargins -> 10], {min, val}, {1, 0}]} addCallout[min_, max_, date_, val_, Right] := {Line@{{max, val}, {date, val}}, ...


11

Preview Notebooks / Extra Paclet Features I decided it was worth it to add some extra features to this thing as it's a good example of what paclets can do for you. First off, I added a little CreateStylesheetPreview function that'll take stylesheets and rasterize them to make a preview. e.g.: CreateStylesheetPreview[ {"Default.nb", "ReverseColor.nb" -&...


11

Style has a PrivateFontOptions option with suboption OperatorSubstitution. With the default setting "OperatorSubstitution" -> True, special characters such as {, (, or [ are replaced by the equivalent characters in a special Wolfram System font. With the setting "OperatorSubstitution" -> False, such characters are not replaced. For ...


10

These issues are unfortunately OS- and font family-dependent, so I will preface that I am working on Windows 7 - 64 bit using MMA 10.2. I currently don't have the Aller font installed on my machine, so I won't yet be able to comment on that one, but I do have Minion Pro. As you mentioned Minion Pro uses lining figure by default. The version installed on ...


10

AxesStyle modifies the Cartesian axes, not the polar ones: PolarPlot[θ, {θ, 0, 4 Pi}, AxesStyle -> {Directive[Thick, Blue], Directive[16, Orange]} ] I could not find a built-in way to modify the polar axes, so after taking a look at the structure of the Graphics object generated by PolarPlot, I came up with the following helper function that modifies ...


10

Things to keep in mind when developing complex GUI in Mathematica: Wolfram System general issues: Styles management/inheritance system (StyleSheets and friend) It is complicated, full of exceptions and only a tip of the iceberg is documented. Those 3 features are limiting the usage of it, which is a pity because it has a potential to give a lot. I'm also ...


10

A couple of images that come with Mathematica. Caveat: There's no guarantee that they will be present in all (future) versions. Button[ Import[FileNameJoin[{$InstallationDirectory, "SystemFiles", "FrontEnd", "SystemResources", "Bitmaps", "Popups", "CodeCompletion", "MenuItemHelpTiny@144dpi.png"}] ], Beep[], (* your help dialog here *) ...


Only top voted, non community-wiki answers of a minimum length are eligible