Tag Info

Hot answers tagged

44

The idea behind this solution is to construct a superposition of Gaussian surfaces whose amplitude decay in time, and use DensityPlot to plot the trail: trail[fun_, {t_, tmin_, tmax_, dt_}, k_, lam_][xxx_, yyy_] := Module[{trange, xrange, yrange, twindow, trailf, sel, decayf}, decayf[x0_, y0_, t0_] := Exp[-k t0 - lam^2 (x0^2 + y0^2)]; twindow = 6/k; ...


37

Solution 1: Using 3D Texture with Polygons The idea is to use Polygon with 3D texture supported by Texture, but it requires a bit of undocumented hack to make it smooth. The original data set is from Stanford Graphics Group website. The dataset that has been used is CThead, 8-bit tiffs (download). Before proceed, make sure that you have a plenty of memory ...


37

Here is a simple approach to create a ghost trail: obj[{xfunc_, yfunc_}, rad_, lag_, npts_][x_] := MapThread[ {Opacity[#1, ColorData["SunsetColors", #1]], Disk[{xfunc@#2, yfunc@#2}, rad Exp[#1 - 1]]} &, Through[{Rescale, Identity}[Range[x - lag, x, lag/npts]]]] frames = Most@Table[Graphics[obj[{Sin[2 #] &, Sin[3 #] &}, 0.1, 1, 500][u], ...


35

The undocumented System`Dump`showStringDiff function neatly does the diff and highlights it for you. The simplest usage is: System`Dump`showStringDiff[text1, text2] You can choose custom colours for the highlights with the Styles option. You can also change the background, font weight, add a strikethrough, etc.: System`Dump`showStringDiff[text1, text2, ...


26

If what you want to visualize is how good the fit is, then you should do as @whuber suggests and plot the residuals, that is, the difference between the data and the fitted function. Below, each data point is drawn as a point with area proportional to the magnitude of the residual. Red means that the data value is higher than the fit; blue means the data is ...


25

Yet another method: Let us calculate values of function on appropriate rectangular grids, which we will convert to textures (1 pixel = 1 value). Interpolation between pixels is built-in. f = 2 #1^2 + 2 #2^2 + #3^2 + #1 #2 &; PolyhedronData["Cube"] // N // Normal // toTriangles // texturize[f, 50, Hue, Lighting -> "Neutral", Axes -> True] ...


23

Based on that outdated notebook, I did the following function: VennDiagram2[n_, ineqs_: {}] := Module[{i, r = .6, R = 1, v, grouprules, x, y, x1, x2, y1, y2, ve}, v = Table[Circle[r {Cos[#], Sin[#]} &[2 Pi (i - 1)/n], R], {i, n}]; {x1, x2} = {Min[#], Max[#]} &[ Flatten@Replace[v, Circle[{xx_, yy_}, rr_] :> {xx - rr, xx + rr}, ...


22

One can also use MeshFunctions: Clear[f]; f = {x, y, z} \[Function] x + Sin[5 z] + y^2; cube = PolyhedronData["Cube", "RegionFunction"]; mesh = 15; RegionPlot3D[cube[x/2, y/2, z/2], {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, MeshFunctions -> {f}, Mesh -> mesh, MeshShading -> ColorData["Rainbow"] /@ Range[0, 1, 1/(mesh + 1)], PlotPoints -> 50, ...


21

What about perceived co-operative strength (well, at least something derived from counting the times two candidates were mentioned together): t = 1/Table[ Count[votes, _?(MemberQ[#, i] && MemberQ[#, j] &)], {i, 6}, {j, 6}]/. ComplexInfinity -> DirectedInfinity[1] // Quiet Do[t[[i, i]] = DirectedInfinity[1], {i, ...


21

With small tables of values, complex graphics can obscure the data. Ed Tufte has recommended just showing the counts. He also points out the worth of presenting the values in a meaningful order: here, the rows go from first to third place while the columns are (roughly) in order of the standings. raw = Import[ ...


21

This could provide a good starting point, since the structure of the diagrams is simply a cross with four regions that themselves can contain similar crosses, you can simply define a structure to represent this nesting and a recursive function to draw such structures. In my implementation I just use the head c to indicate a cross: dirs = {{1, 0}, {0, 1}, ...


21

Edit: I added more explanations below, because this visualization method is quite different from conventional vector plots For just this purpose I had at some point invented the following visualization technique. I'll reproduce your definition first. It defines a complex vector field on the surface of a unit sphere. Clear[\[Epsilon]];(*Polarization ...


20

With a bit of blur, but still not the variable-width blur in the example. obj[{xfunc_, yfunc_}, rad_, lag_, npts_][x_] := With[{trail = Range[x - lag, x, lag/npts]}, {ColorData["SunsetColors"]@#1, Opacity@#1, Disk[{xfunc@#2, yfunc@#2}, rad]} & @@@ Transpose[{Rescale[trail], trail}]] frames = Most@ Table[ImageCompose[# ~Blur~ 4, ...


18

Here's a start (perhaps it's better to say continuation since you've already gotten started): Row@Flatten[sa /. {a_, b_} :> { Style[a, Red], "(", Style[b, Green], ")"}] By capturing the word fragmentth to the left and right of a, you thhould be able to end up with thomething more like:


18

Take $r=1, t=5, d=10$ for example: r = 1; t = 5; d = 10; The parametric equation for the 3-torus is given by: torus3 = {(r + (t + d Cos[a]) Cos[b]) Cos[c], (r + (t + d Cos[a]) Cos[b]) Sin[c], (t + d Cos[a]) Sin[b], d Sin[a]}; Suppose the plane is determined by its normal $\mathbf n$ and a point $\mathbf o$ on it: \[DoubleStruckN] = ...


17

It does seem that the options PeriodicInterpolation -> True and Method -> "Spline" are incompatible, so I'll give a method for implementing a genuine cubic periodic spline for curves. First, let's talk about parametrizing the curve. Eugene Lee, in this paper, introduced what is known as centripetal parametrization that can be used when one wants to ...


17

If you're stuck with the terminal, but have access to X11 and Java, then I suggest using JavaGraphics`, which allows you to display plots, but continue to work in the terminal. This was also answered here, but I learnt it from from Jens. If you really want an ASCII plot, I suggest using the Terminal` package that gives you an ASCII plot: << Terminal` ...


17

It seems networkx uses the D3 library and the example is based on this. We can adapt that code to work with Mathematica and generate JSON output from Mathematica. Save the HTML from the linked page to index.html. Change miserables.json in the source code to graph.json. Generate JSON with Mathematica: g = RandomGraph[BarabasiAlbertGraphDistribution[100, ...


17

One key function you might need is the (undocumented) function Graphics`Mesh`InPolygonQ[], which tests if a point is inside a given polygon. With it, and a few other tweaks, here's my version of weatherMap[]: weatherMap[region_String, property_String, res_Integer: 25, opts___] := Module[{fmin, cmax, coords, pts, minLong, maxLong, minLat, maxLat, ...


17

Something to get you started? f[{x_, y_}] := -Cos[x] x^2 - y^2 xy = First[ ContourPlot[f[{x, y}], {x, -1, 1}, {y, -1, 1}]] /. {x_?AtomQ, y_?AtomQ} :> {x, y, 1}; xz = First[ ContourPlot[f[{x, y}], {x, -1, 1}, {y, -1, 1}]] /. {x_?AtomQ, y_?AtomQ} :> {x, -1, y}; yz = First[ ContourPlot[f[{x, y}], {x, -1, 1}, {y, -1, 1}]] /. ...


16

tl;dr Final results first: (*Function Definition*) ClearAll[opaFun]; Options[opaFun] = Options[ListPlot]; opaFun[points_, opts : OptionsPattern[]] := Module[{f, steps = 10 }, f[x_] := Min[Norm /@ Flatten[ImageData@ ListPlot[points, opts, Axes -> False, PlotStyle -> {Black, Opacity[x]}],1]]/Sqrt@3; Return@NestWhileList[{#, f[#]} ...


16

Let's do real world application. Give the members of the Dow Jones Industrial Average: mem = FinancialData["^DJI", "Members"] {"AA", "AXP", "BA", "BAC", "CAT", "CSCO", "CVX", "DD", "DIS", "GE", "HD", "HPQ", "IBM", "INTC", "JNJ", "JPM", "KFT", "KO", "MCD", "MMM", "MRK", "MSFT", "PFE", "PG", "T", "TRV", "UTX", "VZ", "WMT", "XOM"} Get ...


16

I would try plt=Show[ListPointPlot3D[data, ColorFunction -> "Rainbow"], Plot3D[fit["BestFit"], {x, 0, 180}, {y, 0, 0.1}, PlotStyle -> Directive[Yellow, Specularity[White, 20], Opacity[0.3]]], BoxRatios -> {1, 1, 1}] Then you can change perspective? GraphicsArray[{{plt, Show[plt, ViewPoint -> Front]}, {Show[plt, ViewPoint ...


16

With the set-up you already have, you can do nearbin = Nearest[Table[verttri[[i]] -> i, {i, Length@verttri}]]; counts = BinCounts[nearbin /@ data, {1, Length@verttri + 1, 1}]; which counts the number of data points nearest to each vertex. Then just draw the glyphs directly: With[{maxCount = Max@counts}, Graphics[ Table[Disk[verttri[[i]], 0.5 ...


15

Here are two suggestions for the function f[z_] := 1/z; First, instead of defining a region to omit from your plot, you should base the omission criterion on the length of the vectors (so that you don't have to adjust the criterion manually when switching to a function with different pole locations). That can be achieved like this: With[{maximumModulus = ...


15

You get nice Venn diagrams using W|A, eg.: = (A inter B) un (C inter D) the inter is esc inter esc and the un is esc un esc or skipping the opening = which doesn't work in the midst of a program: WolframAlpha["(A \[Intersection] B) \[Union] (C \[Intersection] D)", \ {{"VennDiagram", 1}, "Content"}]


15

I just had a look at the colours as they are produced on my screen. I have been working with lasers for many (30+) years and can assure you that a 591nm laser line is fairly yellow, around 635nm is fairly red and 488nm appears as cyan, which resembles the colours of the disks well. Are you sure you are not confusing the wavelength of the maximum of black ...


15

I like to draw the predicted and actual responses and connect them with a little line. That shows where the fit is good and where it isn't. With[{ actualpredicted={ data, Transpose[ Append[ Transpose[ fit["Data"][[All,{1,2}]]], fit["PredictedResponse"] ] ] } }, Show[ ListPointPlot3D[actualpredicted, ...


15

To visualize directional information between the two signals, it is sufficient to cross-correlate them and look at the time lags. If the signal in, say, microphone A lags that in microphone B, then it implies that the source was closer to B than A. As you move around the room, the lag should change appropriately depending on the sine/cosine (depending on the ...


14

Many legends can be easily created using combination of Row and Column, where for example, each Row contains two elements: a Graphics expression, and a text label which need not be wrapped in Text. However, since the label you want involves size coding, this method doesn't work. Further, you want to match the size of Disks in the main graphics to the size ...



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