Hot answers tagged

13

Define a new type of symbol (context) called highlight, SetOptions[$FrontEndSession, AutoStyleOptions -> {"SymbolContextStyles" -> {"highlight`" -> Green}}] AppendTo[$ContextPath, "highlight`"]; and before those important variables (symbols) appear for the first time, tell Mathematica to add them to the highlight context (e.g. var1 and ...


8

You can do this with the Filling option. Change Green to Opacity[0] if you don't want it. f[x_] := Sin[2*Pi*x] Plot[{f[x], 0}, {x, 0, 2}, Filling -> {1 -> {{2}, {Red, Green}}}] Edit: to achieve what you want in your edit you can use a Sign function: f[x_] := Sin[2*Pi*x] Plot[{Sign[-f[x]], f[x]}, {x, 0, 2}, Filling -> {1 -> Bottom}, ...


5

Plot[{f[x], ConditionalExpression[0, f[x] < 0]}, {x, 0, 2}, PlotStyle -> {Black, None}, Filling -> {2 -> {Bottom, Red}, 2 -> {Top, Red}}] Plot[{f[x], f[x], ConditionalExpression[0, f[x] < 0]}, {x, 0, 2}, PlotStyle -> {Directive[AbsoluteThickness[5], White], Black, None}, Filling -> {3 -> {Bottom, Red}, 3 -> {Top, Red}}] ...


5

Use EdgeTaggedGraph to get a list of tagged edges, Define the association coloring using tagged edges, and Modify eShapeFunction so that curved edges are preserved edges = DirectedEdge @@@ {{a, h}, {a, h}, {a, h}, {f, e}, {b, c}, {b, d}, {b, e}, {g, d}, {h, c}}; edgecolors = {{Blue, Green}, {Red, Blue}, {Purple}, {Purple}, {Blue}, {Red, ...


5

BarLegend[{ColorData["ThermometerColors"]@Rescale[#, MinMax@TestArray, {.5, 1}] &, MinMax@TestArray}, ColorFunctionScaling -> False, LabelStyle -> {FontSize -> 13, FontFamily -> "Verdana", FontWeight -> Bold}, LegendFunction -> "Frame"] An easier way to get the legend is to use the option PlotLegends in MatrixPlot and ...


4

I'm not quite sure what the reason is, but it looks like neither PlotRange -> All nor PlotRange -> Full are correctly capturing the real plot range. It's especially weird to me since the legend seems to say that the range goes from 0 to 0.25. First I tried SliceDensityPlot3D with PlotPoints -> 120 and PlotRange -> Full to try and see what was ...


3

Update: An alternative ChartelementFunction that gives curved edges: ClearAll[ eSF] eSF[clr_Association] := GraphComputation`GraphChartDump`pEdge[True, blah, blah, #1, #2]/. Style[circle_Circle, _] :> circle /. Circle[center_, radius_, angles_] :> MapThread[Function[{x, y}, {x, Circle[center, radius, y]}], {clr@#2, Partition[...


3

Here is a general, but slow method, which uses DensityPlot[] to generate the shading. To make things more interesting, I'll use a different function: f[x_] := Exp[(x - 5)/10] BesselJ[0, x] (BesselJZero[0, 3] - x) (x - BesselJZero[0, 4])/20 {xmin, xmax} = {0, 25}; pl = Plot[f[x], {x, xmin, xmax}]; {ymin, ymax} = Last[Charting`get2DPlotRange[pl]]; shade = ...


2

I would recommend generating a list of Point objects encapsulated in Style directives to feed to Graphics: newcoloredData = Style[ Point[{#1, #2}], {#3, #6} /. {{0, 0} -> Gray, {0, 1} -> Black, {1, 0} -> Red} ]& @@@ Flatten[data, 1]; Graphics[{coloredData}, Axes -> True] Note also that, rather than Flattening your data all ...


2

If you want to see inside a 3D object, I recommend that you peal back the object to the depth of interest using Manipulate. Clear["Global`*"] w = 0.02; a0 = 1.5; a = {1, 0.9/a0, 0.6/a0}; {R1, R2} = {{-a[[1]] Sqrt[1/4 - (w/(1 - a[[3]]))^2], 0, w/(1 - a[[3]])}, {a[[1]] Sqrt[1/4 - (w/(1 - a[[3]]))^2], 0, w/(1 - a[[3]])}}; maxX = 1.2 R2[[1]]; maxY = ...


2

Perhaps something like this: ColorConvert[ PixelValue[im, pos], OptionValue[Options[im], ColorSpace] -> ImageColorSpace[im] ] where im is an image and pos is a pixel position, e.g., {100, 150}. The basic idea is to use ColorConvert to automatically get the correct head for the image's colour space (e.g. RGBColor or CMYKColor). For this, we need the ...


1

Clear["Global`*"] vars = {x, y}; r[c_] = Solve[Join[Thread[ {x (1 - (x + y/2)/c), y (1 - (x/2 + y))} == {0, 0}], Thread[vars > 0], {0 <= c <= 3}], {x, y}] // Simplify Plot[Evaluate[Tooltip[vars] /. r[c][[1]]], {c, 0, 3}, AxesLabel -> {Style["c", 14, Bold], None}, PlotLegends -> Placed[ (Style[#, 14, Bold] & /@ vars), {.8, ...


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