Hot answers tagged visualization
34
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, ...
33
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 ...
25
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 ...
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}, ...
19
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, ...
19
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[
...
18
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
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] = ...
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
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:
15
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 ...
15
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 ...
15
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, ...
14
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 ...
14
Since BubbleChart does the scaling of the bubbles the trick is to let it draw the circles of the legend too. I do that by adding the legend circles to the plot data. The rest of the graphics can be added using Show.
lc = Append[Reverse@CityData[#, "Coordinates"],
CityData[#, "Population"]
] & /@ CityData[{Large, "USA"}];
steps = 8;
...
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 ...
14
With this function a random integer is inserted in the e-mail address (gmailuser@gmail.com becomes gmailuser+randominteger@gmail.com) and then the hash value is computed. The hash value is used to get the corresponding identicon from the Gravatar website. This approach can address also some privacy concerns.
generatePic[email_] :=
Module[{emailparts, ...
14
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, ...
13
Based on Vitaliy Kaurov's code, I would like to present another approach for making the matrix, which does not depend on Overlay:
mem = FinancialData["^DJI", "Members"];
findata =
FinancialData[#, "Price", {{2000}, {2010}, "Month"}][[All, 2]] & /@
mem[[-10 ;; -1]];
fincm = Correlation[Transpose@findata];
tb = Map[Item[NumberForm[#, 2],
...
13
If we assume that the votes are listed in the order they were cast, we can look at how the race evolved over time during the election period and monitor step by step who were in the leading positions. In this case I'm just calculating the number of votes without taking into account the rank.
Here the very dirty code to create this animation:
data = ...
13
Edit: actually this is very redundant with chris' answer. I keep it for the moment though.
I like to style the data points according to offset from the fit:
Show[{
Plot3D[fit[x, y], {x, 0, 175}, {y, 0., 0.1},
ColorFunction -> "DarkRainbow",
PlotStyle -> None,
Mesh -> 10],
ListPointPlot3D[Partition[data, 1],
...
12
At the risk of stating the obvious (and also not directly answering the question):
A ListPlot with opacity less than 1 is very very similar to a histogram, so why not just use that?
theData = RandomReal[NormalDistribution[], {10000, 2}];
opts = {ColorFunction -> Function[c, GrayLevel[1 - c]],
PlotRange -> {{-4, 4}, {-4, 4}}, ImageSize -> ...
12
How about a BubbleChart3D showing the three choices as 3 axes:
names = {"??", "RM", "JM", "Vb", "Wz", "Fx", "EK"};
data = Tooltip[Flatten[{##}],
ToString[names[[1 + #1]]] <> " : " <> ToString[#2]] & @@@ Tally[votes];
With[{tt = Transpose[{Range[0, 6], names}]},
BubbleChart3D[data,
AxesLabel -> Framed /@ {"First", "Second", ...
12
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 ...
12
Using How to join two Style[]d strings, we can get a decent looking display on the the test case
Flatten[Map[If[Length[#] == 2, {Style[#[[1]], Red, FontVariations -> {"StrikeThrough" -> True}], Style[#[[2]], Green]}, #] &, sa]];
Apply[StringJoin, ToString[#, StandardForm] & /@ %]
Note that with this method text correctly wraps across lines
...
12
map = Import["http://upload.wikimedia.org/wikipedia/commons/e/e3/China_old_map.jpg"]
{w, h} = map // ImageDimensions;
The route:
route = {{1107.07`, 184.181`}, {1096.17`, 198.195`}, {1072.81`, 237.121`}, {1071.25`, 244.906`}, {1068.14`, 254.249`}, {1065.03`, 265.148`}, {1063.47`, 274.49`}, {1063.47`, 286.947`}, {1063.47`, 296.289`}, {1063.47`, 308.746`}, ...
12
Here's your approach, but with 3D primitives. You can then move the camera around using your own definition for ViewVector (or you can steal Sjoerd's):
Module[{mapZ = 0, mapDim = ImageDimensions@map, arrowZ = 5, ordering},
Graphics3D[
{
{Texture@map,Polygon[
List[##, mapZ] & @@@ Tuples[Transpose@{{0, 0}, mapDim}] ...
12
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 ...
11
Another interesting way of looking at the voting data would be to visualize the 2nd and 3rd choices for a given 1st choice. In a way, this is a breakdown of Sjoerd's plot when a given candidate is the 1st choice.
For example, among those who voted for me as the 1st choice, they were evenly split between J. M., Mr.Wizard and Verbeia for 2nd choice and a ...
11
You are talking about a list of 3D points and curve fitting. I therefore assume you want a function with a single parameter that describes a curve fitting through your set of points. I don't believe ListInterpolate can handle that.
My alternative is the following.
First, a set of 3D points:
pts1 = Table[{Sin[t], Cos[t], Cos[t] Sin[t]}, {t, 0, 2 \[Pi], ...
Only top voted, non community-wiki answers of a minimum length are eligible
