Hot answers tagged

56

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, ...


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 ...


38

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....


30

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"...


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 ...


24

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 ...


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,...


15

As I mentioned in a comment, you can do something like this to have different styles for the frame, ticks, tick marks, plot label, and frame labels. Plot[2 Sin[x], {x, 0, 10}, Frame -> True, FrameLabel -> {x, y}, PlotLabel -> 2 Sin[x], FrameStyle -> Directive[Green, FontColor -> Orange], FrameTicksStyle -> Directive[Yellow, ...


14

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]


13

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 -> ...


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

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. ...


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}, {-...


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

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[...


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}}, ...


10

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]


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

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["\"...


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

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 *) ...


10

Here's the general way this type of thing seems to be handled in the built-in things plus code to build the type of buttons you want. First the button code: makeDisk[gradSpec_, n_] := Rasterize[ Module[{img, disk, edge}, img = RadialGradientImage[ gradSpec, n ]; Graphics[ { Inset[img, Center, Center, Scaled[1]]...


9

To prevent your second invocation of SetOptions from resetting the value of sub-option "SymbolContextStyles", you need to set both "System" and "Global" sub-sub-option values at once: SetOptions[EvaluationNotebook[], "AutoStyleOptions" -> {"SymbolContextStyles" -> {"System`" -> RGBColor[211./255, 54./255, 130./...


9

I don't know if any of them can be callled documented but I know three ways to do this: mentioned above: FrontEndToken way: ( SelectionMove[#, All, Cell]; FrontEndTokenExecute[EvaluationNotebook[], "Style", "Title"] ) & /@ Cells[CellStyle -> "Section"] or SelectionSetStyle way: ( SelectionMove[#, All, Cell]; MathLink`CallFrontEnd[FrontEnd`...


9

Update 2: A much more convenient approach to construct a custom EdgeShapeFunction to style multi-edges individually: styles = Association[PropertyValue[g1, EdgeStyle]] ; esf = {Dashing[{}], First[styles[#2] = RotateRight[styles[#2]]], Arrowheads[Large], Arrow[#, .1]} &; Graph[g1, EdgeShapeFunction -> esf] Update: To make it more convenient to ...


9

ParametricPlot[ v {Cos[u], Sin[u]}, {u, 0, 2 Pi}, {v, 1, 3}, Mesh -> {15, 3}, Epilog -> { PointSize @ .02, Red, Point @ Catenate @ Array[ Function[{u, v}, v {Cos[u], Sin[u]}], {15 + 2, 3 + 2}, {{0, 2 Pi}, {1, 3}} ] }] As pointed by Shutao TANG, Catenate is new so one can ...


9

Edit My previous answer was just a workaround, and it involved putting the color as a graphics directive for the individual plotmarkers. My thanks to @rcollyer for bringing an undocumented option to my attention which is the true solution to this problem. You just need to set Method -> {"OptimizePlotMarkers" -> False} ListPlot[Table[ Style[{Cos[...


9

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 ...


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