# Tag Info

89

TL;DR: A package (Mathematica v10) can be found at the very bottom of this post. UPDATES 6: Tiny update: Import can now use the ".bvh" extension to determine the import type. The code that does this is ugly, but I don't see any other way at the moment. out = Import["C:\\Female1_C03_Run.bvh"] 5: Added error checking and registered the package as an ...

84

Here's a way to morph the boundaries. After finding the boundaries by Thinning of the result of EdgeDetect, FindCurvePath finds a sequence of points that traces a path around each segment. MorphologicalComponents numbers the component left to right, top to bottom, so that 1 is the apple leaf, 2 is the i-dot, 3 is the apple body, and 4 is the i-stem (5, 6 ...

66

A major point behind the video is that Mobius transformations are simplest when viewed on the sphere. Thus, we'll never actually define a Mobius transformation - we'll do that part on the sphere. Of course, we will need to project back and forth. Here are the stereo graphic projection and it's inverse implemented as compiled functions for speed. This is ...

55

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

51

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

51

I've taken the liberty of uploading the RGB values for MyCarta's color schemes to pastebin. Mr. Niccoli provides these in CSV downloadable from his website, but I found that I had to change their format if I want Mathematica to read them during initialization. (* Read in the numerical data *) Get["https://pastebin.com/raw/gN4wGqxe"] ParulaCM = With[{...

49

One way to do it would be to use glyphs. We can extract the curves that make up the two characters as follows: a = First@First@Last@First@First@ ImportString[ExportString[ Style[FromCharacterCode[61440], 24, FontFamily -> "Baskerville Old Face"], "PDF"], "PDF", "TextMode" -> "Outlines"]; b = First@First@Last@First@First@ ...

49

Here's the start of a SankeyDiagram function: Options[SankeyDiagram] = Join[ {ColorFunction -> {"Start" -> ColorData[97], "End" -> ColorData["GrayTones"]}}, Options[Graphics] ]; SankeyDiagram[rules_, opts:OptionsPattern[]]:=Module[ { startcolors, svalues, slens, startsplit, endcolors, evalues, elens, endsplit, len, endpos,...

47

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

46

Disclaimer: I didn't actually look at the links in the comments because I wanted to see how well I could do on my own, so here's my original Mathematica cartogram creation! First, load the data from various web resources (as is done here): ClearAll["Global*"] usa = Import[ "http://code.google.com/apis/kml/documentation/us_states.kml", "Data"]; ...

44

Edit note: I want to thank to all upvoters, this is really shocking and motivating :). Just to make this answer covering both graphs I've added right graph made with SectorChart like I suggested in comments and to not clone David's solution. data = RandomReal[{1, 5}, 16]; Left graph: For equally spaced (in angle) measurements it is easier to use Mesh for ...

44

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 This function is available in the function repository, and the source code ...

44

TUTORIAL Import Image img = Import["https://i.stack.imgur.com/xzcUg.jpg"] Split into Components Using this approach (credit: nikie): m = MorphologicalComponents[Binarize@ColorNegate[ColorConvert[img, "Grayscale"]]]; Colorize[m] components = ComponentMeasurements[{m, img}, {"Area", "BoundingBox"}, #1 > 100 &]; trim = ImageTrim[img, #] & /@ ...

42

The undocumented SystemDumpshowStringDiff function neatly does the diff and highlights it for you. The simplest usage is: SystemDumpshowStringDiff[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.: SystemDump`showStringDiff[text1, text2, ...

41

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

38

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

38

Let us do it purely by image-processing. The main idea is to use DistanceTransform here. {img1, img2} = ImageResize[#, Scaled[3]] & /@ Import /@ {"http://i.stack.imgur.com/RKHo5.png", "http://i.stack.imgur.com/MFGR4.png"} The signed distances to the boundaries of all morphological components are dist = ImageData@ImageSubtract[...

37

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[ϵ];(*Polarization vector*)ϵ[λ_] = ...

36

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

36

Some function definitions first. AkimaInterpolation[] stolen from here: AkimaInterpolation[data_] := Module[{dy}, dy = #2/#1 & @@@ Differences[data]; Interpolation[Transpose[{List /@ data[[All, 1]], data[[All, -1]], With[{wp = Abs[#4 - #3], wm = Abs[#2 - #1]}, If[wp + wm == 0, (#2 + #3)/2, (wp #2 + wm #3)/(wp + wm)]] & @@@ ...

36

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

36

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

35

In 2D unitCell[x_, y_] := { Red , Disk[{x, y}, 0.1] , Blue , Disk[{x, y + 2/3 Sin[120 Degree]}, 0.1] , Gray, , Line[{{x, y}, {x, y + 2/3 Sin[120 Degree]}}] , Line[{{x, y}, {x + Cos[30 Degree]/2, y - Sin[30 Degree]/2}}] , Line[{{x, y}, {x - Cos[30 Degree]/2, y - Sin[30 Degree]/2}}] } This creates the unit cell Graphics[unitCell[0, 0], ...

34

Let you have a function and an initial point f[x_] := Cos[x] x0 = 0.2; Then you can calculate a sequence seq = NestList[f, x0, 10] (* {0.2, 0.980067, 0.556967, 0.848862, 0.660838, 0.789478, \ 0.704216, 0.76212, 0.723374, 0.749577, 0.731977} *) and vizualize it with a so-called Cobweb plot p = Join @@ ({{#, #}, {##}} & @@@ Partition[seq, 2, 1]); ...

32

You can also calculate the Coefficient of Determination, R Squared. This is the same as the correlation squared, but by making use of LinearModelFit you can create some additional graphics. To make a sample distribution you can use this: CreateDistribution[] := DynamicModule[{savepts = {{-1, -1}}}, Dynamic[ EventHandler[ ListPlot[pts, AxesOrigin -...

31

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"}]

31

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

31

Update: I wrapped all this up into a small package for those who don't want to go through all the steps but would like to try this out anyway. Warning: There's not a lot of error checking and it may be very slow for more than a couple of hundred nodes. The other answer I wrote shows how to use the builtin functionality. In this answer I am going to show ...

31

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

31

With a pie chart around it: clusterSector[gap_][{{xmin_, xmax_}, y_}, rest___] := Block[{ngap = Min[(xmax - xmin)/2, gap]}, {EdgeForm[White], ChartElementData["Sector"][{{xmin + ngap, xmax - ngap}, y}, rest]}]; iCoord[{i_, j_}, bin_: 60] := Through[{Cos, Sin}[ Pi/2 - \[Pi]/5 i - (\[Pi]/5)/bin (j - 1) - 0.025]]; iCurve[{x_, y_}, rad_: 15, ...

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