Hot answers tagged

35

I've taken the liberty of converting the pseudocode from Moreland's paper into a package. I had to change the numerical values of the RGB->XYZ transformation matrix to account for the fact that Mathematica uses different reference white points for the different color spaces. Update I've created a package, and uploaded it on on github. Much thanks to J.M.,...


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", "http://files....


24

This response defines a function called traceTypes which provides a quick-and-dirty visualization of type system operation. The function is somewhat fragile as it depends upon undocumented implementation details in version 10.2. Despite this fragility, it might be useful for study purposes as it handles many common type system use cases. The code for the ...


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


19

Here's my take (using some of the new version 10 functions): adjusthue[msat_, ssat_, hsat_, munsat_] := hsat + (1 - 2 UnitStep[-hsat - π/3]) If[munsat == msat, 0., Sqrt[Max[1, munsat/(msat + $MachineEpsilon)]^2 - 1]/Sinc[ssat]] l2m = With[{m = Norm[{##}]}, {m, ArcCos[If[m == 0, 0, #1/m]], Arg[#2 + I #3]}] &; m2l = #1 Prepend[Sin[#2] ...


17

This was supposed to be a comment to Jason's answer, but it got a bit long. But wouldn't it be cool if you could just input a DNA sequence and have a plot? ... take that little snippet and paste it into the form on this site, then you can download a PDB file to import... By looking through the source of the make-na server form, I was able to figure out ...


15

This plot is an example of a "force layout". Note that the same thing is happening on two levels. The continents are fighting for space, as are the countries inside the continents. We need to figure out how to implement this fighting for space within a predetermined region. There are six continents, so first we pick six random points in the unit disk: ...


13

You ought to use EdgeRenderingFunction to achieve this. First, import a graphic for a brushstroke: BRUSH = Import[NotebookDirectory[] <> "brush.png"] Then use the EdgeRenderingFunction option in GraphPlot to obtain the image. GraphPlot[Graph[{1 -> 2, 2 -> 3, 3 -> 1}], EdgeRenderingFunction -> ({Inset[BRUSH, Mean[#1], Automatic, 1.7, #[...


12

Here is a simple-minded smooth homotopy between the two curves in the OP, using a Hermite interpolant for keyframing: hcubic[t_] = InterpolatingPolynomial[{{{0}, 0, 0}, {{1}, 1, 0}}, t]; Animate[ContourPlot[(1 - hcubic[t]) ((x^2 + y^2 - 1)^3 - x^2 y^3) + hcubic[t] (x^2/2 + y^2/3 - 1) == 0, {x, -3/2, 3/2}, {y, -7/4, 7/...


11

Although this is hardly a debilitating bug I wondered what else might be affected so I decided to trace this further. I found that the bug affects TreeForm by way of TreePlot. Here is a reduced example of the call that originates in the exhibit above: TreePlot[{1 -> 2, 1 -> 3, 1 -> 4}, Top, 1, "VertexNames" -> {List, HoldForm["foo"], ...


11

In order to make the legend properly, I elected to use the CustomTicks package, available here. The code for the density plotting function is << "CustomTicks`"; Options[nonLinearDensityPlot] = {"SignedData" -> Automatic, "ScalingFactor" -> 100, "Color" -> Automatic, "ScalingFunction" -> (ArcSinh[#1 #2 / #3]/ArcSinh[#2] &)}; ...


10

I would do it like this: The example graph g: g = Graph[{1 <-> 2, 2 <-> 3, 3 <-> 1}]; Desired locations of the vertice in result: vtxPosStore = Association[{ 1 -> {0, 0}, 2 -> {1, 0}, 3 -> {.5, 1} }]; Desired edge-shapes: edgeRoutingStore = Thread[# -> (Join[...


10

You can take Michael Trott's code and modify it a bit to easily plot these surfaces Import["http://www.mathematicaguidebooks.org/V6/downloads/\ RiemannSurfacePlot3D.m"] rsurf[func_] := Grid[{{RiemannSurfacePlot3D[w == func, Re[w], {z, w}, ImageSize -> 400, Coloring -> Hue[Rescale[ArcTan[1.4 Im[w]], {-Pi/2, Pi/2}]], PlotPoints -&...


10

WordCloud a recent function can do some neat tricks beyond the obvious. For example: Wrappers such as Style and Rotate passed to individual words will be preserved in the WordCloud These wrappers can be functions of words, for example their semantics or linguistics Let's consider a list of top ranked baby names in 2015: page = Import["http://www....


9

Code from years ago, adapted for Manipulate, for a pre-calculus course: Move m to see the homotopy. (I used it at the end of the function-graph transformations to show "translating by a function" instead of by a constant.) The other parameters were for finding a good-looking shape for class. You can adapt or add coefficients for the desired "zero." ...


9

Firstly I'm not sure if Mathematica's Random Tree method has an equivalent max_depth option (I don't know too much about random tree). The options available to the Random Tree method are: "TreeNumber", "LeafSize", and "VariableSampleSize". Now as for plotting the classifier boundaries, one can simply pass the ClassifierFunction for ContourPlot (or similar)....


8

As this is a special-functions question, I feel justified in using a bit of heavy artillery. Here goes nothing... In effect, what the OP seems to want to do is to evaluate $$\sum_{n=1}^\infty \frac{(q^{n+1};q)_\infty}{(q^n;q)_\infty} q^{n-1}$$ (where $(a;q)_n$ is the $q$-Pochhammer symbol) by approximating it with its partial sums. However, there is a ...


8

You can do this with GeoLabels: GeoRegionValuePlot[Counts[temp], GeoLabels -> (Tooltip[#1, #2] &)]


8

Another option is to use DenistyPlot3D. You can set your own custom OpacityFunction and ColorFunction (by default they take scaled values between 0 and 1) DensityPlot3D[ 1/(1 + x^2 + y^2 + z^2), {x, -5, 5}, {y, -5, 5}, {z, -5, 5}, PlotPoints -> 100, OpacityFunction -> Function[f, (Exp[4 f] - 1)/(E^4 - 1)], ColorFunction -> (ColorData["...


8

I find a decent result by using the two-argument version of WordSpacings, where the first number is along the word's direction (horizontal here) and the second is perpendicular to it (vertical here). Further, if I give it the same image dimensions as the wordle version above, the result is very similar WordCloud[Scores, WordSpacings -> {10, 3}, ...


8

You can plot the surface and the vector fields separately and then combine them together. Here is an example. Consider the spherical radius r can be written as function $r(\theta,\phi)$: mysurface[θ_, ϕ_] = FullSimplify[Re[SphericalHarmonicY[3, 2, θ, ϕ]], Assumptions -> {θ ∈ Reals, ϕ ∈ Reals}] (* 1/4 Sqrt[105/(2 π)] Cos[θ] Cos[2 ϕ] Sin[θ]^2 *) ...


7

Here is a version that builds up the "full Tufte" version of the plot presented above by building up the corresponding Graphics primitives. Quite a few styling decisions must be made with respect to colors, spacings, overall aspect ratio of the plot, etc. I went with choices that were aesthetically pleasing to me, but of course it should be relatively easy ...


7

Here is some code I used, which may partially answer your question. The key is to calculate efficiently points near the border of the Mandelbrot set. These points have large iteration counts which, when iterated, produce the Buddhabrot form. The algorithm linked to in the question uses an adaptive mesh of squares to locate border points. The alternate code ...


7

From Version 10.2 upwards we can now use SliceContourPlot3D and SliceDensityPlot3D to achieve this: SliceContourPlot3D[x + Sin[5 z] + y^2, "CenterCutBox", {x, -0.5, 0.5}, {y, -0.5, 0.5}, {z, -0.5, 0.5}, Boxed -> False, Axes -> False, Contours -> 20, ColorFunction -> Hue] You can increase Contours to 10 or higher to ...


6

A series of n cosine functions at successively doubled frequencies can be phased so their signs produce a Gray Code (– for 0, + for 1). If these cosines are also scaled to successively halved amplitudes, they partition the plane over one major cycle into 2^n non-overlapping regions, just like the circles of a Venn diagram. These regions cover the angle axis ...


6

In version 10.2 there is a new suite of functions that may be helpful: f[x_, y_, z_] := Sin[x/4]*Sin[y/4]*Sin[z/4]; xyzw = Flatten[Table[{x, y, z, f[x, y, z]}, {x, 1, 10}, {y, 1, 10}, {z, 1, 10}] // N, 2]; ListSliceContourPlot3D[xyzw, "CenterPlanes"]


6

Use Kellen Myers's method but with randomly generated brush-style strokes: Clear[baseStroke] baseStroke := Graphics[{ Black, FilledCurve@ BSplineCurve[{{2,0},{1,0},{0,-0.2},{-0.1,0},{0,0.2},{1,.1}}, SplineClosed -> True] }, PlotRange -> {{-.3, 2}, {-.5, ....


6

Here is a slight simplification of Jason's code for scaled density plots: Needs["CustomTicks`"]; Options[nonLinearDensityPlot] = {"ColorFunction" -> Automatic, "ScalingFactor" -> 100, "ScalingFunction" -> Automatic, "SignedData" -> Automatic}; nonLinearDensityPlot[func_, {x_, xmin_, xmax_}, {y_, ymin_, ymax_}, plotopts : ...


6

Here is a comparison of your function (adequately post-processed via PiecewiseExpand[] and Expand[]) compiled to "C" and "WVM" with System`BezierFunction[]: exs = Join[{#, Compile[{{x, _Real}, {y, _Real}, {z, _Real}}, Evaluate[Expand@PiecewiseExpand[CAGDBezierFunction[pts][x, y, z], Thread[0 < {x, y, ...


6

data = Table[ PDF[BinomialDistribution[50, p], k], {p, {0.3, 0.5, 0.8}}]; DiscretePlot[ Evaluate@data, {k, 1, 50}, PlotStyle -> { Directive[Black, Opacity[.5], AbsoluteDashing[{5, 5}]], Directive[Black, Opacity[.5], AbsoluteDashing[{10, 10}]], Directive[Black, Opacity[.5], AbsoluteDashing[{0, 0}]]}, PlotMarkers -> {Automatic,...



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