Hot answers tagged

53

Edit: Added the reversal and some refinements ω = 1; posP[t_, φ_] := Sin[ω t + φ] {Cos[φ], Sin[φ]} posL[φ_] := {-#, #} &@{Cos[φ], Sin[φ]} Animate[ Graphics[{PointSize[0.02], Table[{Black, Line[posL[π i]], Hue[i], Point[posP[t, π i]]}, {i, 0, 1, 1/(3π-Abs[9.43-t])}] }, PlotRange -> {{-1.5, 1.5}, {-1.5, 1.5}} ], {t, 0, 6π, 0.2} ]


51

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


49

If you want to make several sequences of the Collatz function for turning it into a graph, you probably want to memorize, which parts you already calculated. What we try to do is to create a graph like this (image from xkcd) When we would calculate the whole chain for each number until it (hopefully) reaches the end sequence 8,4,1 we do a lot of work over ...


42

I'd like to expand on Quantum_Oli's answer to give an intuitive explanation for what's happening, because there's a neat geometric interpretation. At one point in the animation it looks like there is a circle of colored dots moving about the center, this is a special case of so called hypocycloids known as Cardano circles. A hypocyloid is a curve generated ...


38

Based on Oleksandr's excellent design idea here is my reimplementation of his package which offers much richer set of shapes. How to install the package The most recent version of the package can be installed from GitHub by evaluating the following: (* Load the package code *) package = ...


35

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


34

Fortunately, Wikipedia has the answer, as long as we are content to restrict ourselves to non-intersecting closed polygons. This will probably be an acceptable limitation, given that excessively complicated plot markers tend to look slightly distracting anyway. Because we seek an aesthetic rather than rigorously well defined result, we do not need to be ...


32

Scientific progress! In v10.3 with all the goodies in AnatomyData we can now use the simple code: Entity["AnatomicalStructure", "Skin"]["Graphics3D"] Zoom in on the appropriate part and you're done. pelvisLoc = AnatomyData[Entity["AnatomicalStructure", "Pelvis"], "RegionBounds"]; Show[ Entity["AnatomicalStructure", "Skin"]["Graphics3D"], ...


32

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


32

This can be done more-or-less easily with a combination of options for AxesOrigin, PlotRange, and PlotRangePadding and the CustomTicks package (for easy outward-facing ticks). Needs["CustomTicks`"]; GapAxes[plot_Graphics, ticks : {{x__}, {y__}}, scalefactor_: Automatic] := With[ {prange = ticks[[All, 1 ;; 2]], s = Flatten@{scalefactor /. Automatic ...


31

I feel that once you start with Moire patterns, there's no ending. The way I would replicate these is by making a grid into a function (like @JasonB) but also parametrise the angle of rotation into it: lines[t_, n_] := Line /@ ({RotationMatrix[t].# & /@ {{-1, #}, {1, #}}, RotationMatrix[t].# & /@ {{#, -1}, {#, 1}}} & /@ ...


29

This is the Collatz function I know: Collatz[1] := {1} Collatz[n_Integer] := Prepend[Collatz[3 n + 1], n] /; OddQ[n] && n > 0 Collatz[n_Integer] := Prepend[Collatz[n/2], n] /; EvenQ[n] && n > 0 Generating a graph from this is easy: Graph[(DirectedEdge @@@ Partition[Collatz[#], 2, 1]) & /@ Range[500] // Flatten // Union, ...


27

The easiest way to do this is if you have a PDB file, then it's as easy as using Import. Here are a few examples from the RCSB's Protein Data Bank. To get the URLs, find a page for a given sequence or protein and right-click on the link next to "DOI:" and copy the link. Import[#, "PDB"] & /@ {"http://files.rcsb.org/download/5ET9.pdb", ...


25

Illuminated by @Mr.Wizard's answer, here I provide a complete example of a self-made plot theme, called "Academic". It can be used as a base theme. The axes feature theme is based on the theme "AxesFrame" of "Scientific" with Black, AbsloteThicknees[1], FrontSize->12 axes/frames. The color feature theme is based on "VibrantColor" with modifications of ...


25

Normally Plot uses machine precision numbers; your $x^x$ expression is hitting the limit of the numbers that can be represented in machine precision right about $x>143$. Note: Solve[$MaxMachineNumber == x^x, x] (* Out: {{x -> 143.016}} *) You can increase the WorkingPrecision setting for Plot adequately, and the plot will be complete: f[x_] = ...


24

Source of the problem (possibly) Here is a clear indication that your Fortran library and the Mathematica function are behaving in fundamentally different ways. I noticed the apparent high frequency oscillations in the difference functional, so I decided to see exactly how quickly they oscillate, Plot[funcfortran[w, 0.06, -1.0, 1.0, 1.0, N[π/2], 2.0, 3., ...


23

This package provides couple of functions for plotting commits data from GiHub: Import["https://raw.githubusercontent.com/antononcube/MathematicaForPrediction/master/Misc/GitHubPlots.m"] GitHubDateListPlot["hadley", "plyr"] GitHubBarChart["hadley", "plyr"] I think these plots are similar enough to the image in the question. There are number of ...


23

What you need to do here is to generate a ParametricPlot to give the 2D goat/silo problem, and then we can rotate it with RevolutionPlot3D. From reading the page on MathWorld, we can see that we need to make a circle involute to describe the portion of the area where the goat's circle is limited by the presence of the silo. In Cartesian coordinates, this ...


23

Something like this: nlines = 30; Table[ Overlay[ Rotate[ Graphics[{ Table[{ Line[{{0, n}, {nlines, n}}], Line[{{n, 0}, {n, nlines}}]}, {n, 0, nlines}], Text[Style[#1, 18], {0, 0}, {-1, -1}, Background -> White] }, AspectRatio -> 1, PlotRangePadding -> None, ImageSize -> ...


22

Here is an alternative answer. Of course, since you answered your own question, you may not need this. But I think the following is a viable alternative that may end up looking comparable, and has additional dynamic features. Instead of ListPlot, just use BubbleChart. data = ConstantArray[Range[5], 4] + Range[0, 6, 2]; newData = Map[MapIndexed[Join[#2, ...


22

Update: I have realized since writing this that the below algorithm is not exactly what Plot uses anymore. Given the reference in my reference, a book written by someone who knew Mathematica very well, I guess that the algorithm has been changed in more recent versions of Mathematica. The algorithm that Plot uses is explained in the link provided by ...


21

Graphics[{Circle[{0, 0}, 1, {0, Pi}], Circle[{0, 0}, .03], Line[{{1, 0}, {1, -.1}, {-1, -.1}, {-1, 0}}], Rotate[ Line[{{.03, 0}, {.6, 0}}] , #, {0, 0}] & /@ {0, Pi/2, Pi}, GeometricTransformation[ Piecewise[{ {{Red, Line[{{.8, 0}, {1, 0}}], Black, Line[{{.2, 0}, {.5, 0}}], Rotate[{Red, Text[#, {.75, 0}, {0, ...


21

If you are serious about using this extensively, consider making a function based on CreateDocument... Here is one way to pursue Szabolcs's line of thought. What follows is a function based on CreateDocument[] that can be used in conjunction with the (now somewhat neglected) option DisplayFunction, which handles where the output of graphics functions ...


21

If I'm not mistaken, a complement is defined as the set of elements in one set that are not contained in a given other set. In your case, you have specified the 'other' set (the union of S1, S2 and S3), but not the 'one' set. As you phrased it, I guess that set must be $\mathbb R^3$. So, the complement is the difference between an infinite space and a finite ...


21

There are built-in magnifying glasses. However, spontaneously I don't know how to invoke one directly for a Plot. Therefore I'm going to demonstrate one way that converts the Plot Graphics object into an Image: Image@Plot[Sin[x], {x, 0, 4}] FrontEndExecute[FrontEnd`Select2DTool["GetRectangleImageSelection"]] The image ribbon itself is ...


20

I think SmoothDensityHistogram (docs here) is what you are looking for: data1 = RandomVariate[BinormalDistribution[{0, 0}, {2, 3}, 0.5], 100000]; data2 = RandomVariate[BinormalDistribution[{3, 4}, {2, 2}, .1], 100000]; data = data1~Join~data2; This is just some random sample data. If you plot it using ListPlot, you obtain the "blob" you mentioned: ...


20

Equation taken form the wiki page x[u_, v_] := (1 + (v/2) Cos[u/2]) Cos[u] y[u_, v_] := (1 + (v/2) Cos[u/2]) Sin[u] z[u_, v_] := (v/2) Sin[u/2] plot = ParametricPlot3D[{x[u, v], y[u, v], z[u, v]}, {u, 0, 2 Pi}, {v, -1, 1}, Boxed -> False, Axes -> False]


19

Wanna listen to a story? :) It was around 2002 when I finally became fed up with ParametricPlot3D[] and its inability to adaptively plot space curves. Recall that this was the old Graphics[] system where all the pictures were effectively done in PostScript. Thus, I set out to look for a way to adaptively plot curves in general. I was at the time very ...


19

It definitely has something to do with the Interpolation function. Evaluating tempdata = Import["http://www.inrim.it/~magni/cm.dat.gz", "Table"]; cmfunc = Interpolation[tempdata] we get the warning Interpolation::udeg: Interpolation on unstructured grids is currently only supported for InterpolationOrder->1 or InterpolationOrder->All. Order will ...


18

In the version 10.2, there is a builtin DensityPlot3D function, which can be used to visualize orbitals. a0=1; ψ[{n_, l_, m_}, {r_, θ_, ϕ_}] :=With[{ρ = 2 r/(n a0)}, Sqrt[(2/(n a0))^3 (n - l - 1)!/(2 n (n + l)!)] Exp[-ρ/2] ρ^ l LaguerreL[n - l - 1, 2 l + 1, ρ] SphericalHarmonicY[l, m, θ, ϕ]] DensityPlot3D[(Abs@ψ[{3, 2, 0}, {Sqrt[x^2 + y^2 + z^2], ...



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