Visualization Overview

Brett Champion

Wolfram Research

Topics

AbsoluteOptions

Vector Visualization

Ternary Plots

Scaling Expansions

Plot Styling

AbsoluteOptions

The scene below is an example for which AbsoluteOptions would previously have returned incorrect settings for options like PlotRange, FrameTicks, and ImagePadding.

scene=Graphics[{{GrayLevel[0.1],Rectangle[Scaled[{0,0}],Scaled[{1,1}]]},Table[Translate[Scale[Rotate[{Hue[i/200],Rectangle[{0,0},{1,1}]},i],(Sqrt[2i])],{i Sin[i],i Cos[i]}],{i,200}]},Frame->True]

The option values below now match up with the visual appearance of the scene.

V12.3

Column[AbsoluteOptions[scene,{PlotRange,AspectRatio,ImagePadding,FrameTicks}]]

V13.0

Column[AbsoluteOptions[scene,{PlotRange,AspectRatio,ImagePadding,FrameTicks}]]

Vector Displacement Plots

VectorDisplacementPlot and VectorDisplacementPlot3D are a way of visualizing vector fields, by showing how the vectors displace points in an object.

A constant vector field simply moves all the points in the same direction.  Here the light gray disk is the original object, and the blue disk is the displaced version. The color of the displaced region depends on the magnitude of the displacement.

VectorDisplacementPlot[{1,1},{x,y}∈Disk[]]

Here is a more interesting field applied to an annulus. The lighter orange colors represent larger displacements.

VectorDisplacementPlot[{Cos[x^2-y],Sin[y^2+x]},{x,y}∈Annulus[]]

Turning on the vectors shows the connections between the original and displaced object.

VectorDisplacementPlot[{Cos[x^2-y],Sin[y^2+x]},{x,y}∈Annulus[],VectorPoints->Automatic]

Displacement Plots: 2D Application

The full example below can be found in the documentation here.

Define an L-shaped region that is fixed at the bottom and has a uniform tensile load applied on the top-right edge:

Plot the deformed region and note that the displacements are amplified to make them more visible:

VectorDisplacementPlot[{usol[x,y],vsol[x,y]},{x,y}∈Ω,PlotLegends->Automatic,VectorPoints->Automatic]

Specify an alternate quantity to color the region, in this case von Mises stress.

VectorDisplacementPlot[{{usol[x,y],vsol[x,y]},vonMises},{x,y}∈Ω,PlotLegends->Automatic]

3D Finite Element Application

Compute the deflection of a spoon held fixed at the end and with a force applied to it.

Set up variables and parameters:

vars={{u[x,y,z],v[x,y,z],w[x,y,z]},{x,y,z}};
pars=<|"Material"->LinguisticAssistant|>;

Set up the PDE and the geometry:

spoon=;
{d1,d2,d3}=NDSolveValue[{SolidMechanicsPDEComponent[vars,pars]==SolidBoundaryLoadValue[x>=1/10,vars,pars,<|"Force"->{0,0,(Quantity[-100, "N", newtons, "Newtons"])}|>],
SolidFixedCondition[x<=-1/10,vars,pars]},{u,v,w},{x,y,z}∈spoon];

Visualize the displacement:

VectorDisplacementPlot3D[{d1[x,y,z],d2[x,y,z],d3[x,y,z]},{x,y,z}∈spoon]

Ternary Plots

Typically used for mixtures, ternary plots are a way of visualizing data that consists of three components {u,v,w} as 2D points inside a triangle.

Ternary Plot

TernaryListPlot[Table[{i,r,100-i-r},{i,10,90,10},{r,0,100-i}],PlotLegends->Quantity[Range[10,90,10],"Percent"],FrameLabel->{"A","B","C"},GridLines->Automatic,GridLinesStyle->Black]

TernaryListPlot[Table[{i,r(100-i)/(r+1),(100-i)/(r+1)},{r,{10,4,2,1,1/2,1/4,1/10}},{i,0,100}],]

Ternary Plot Applications

Geology

Plot a soil texture triangle with shaded regions:

TernaryListPlot[, FrameLabel->{"Sand","Silt","Clay"},Prolog->{{Directive[{Opacity[0.5],}],Polygon[{{0.2, 0.6, 0.2}, {0.2, 0.2, 0.6}, {0.6, 0.2, 0.2}}]},}]

Nutrition

Show the fractions of fat, carbohydrates and proteins in a variety of foods:

TernaryListPlot[Tooltip[{##2},#]&@@@,FrameLabel->{"Fat","Carbs","Protein"},PlotStyle->PointSize[.015]]

Energy

Show the sources of electricity for countries around the world:

TernaryListPlot[MapThread[Tooltip[#1,#2]&,{EntityValue[EntityList[(Entity["world", Entity["GeographicRegion","World"], "Entity[\"GeographicRegion\", \"World\"]", "geographic region"])[(EntityProperty["countries", EntityProperty["GeographicRegion","Countries"], "EntityProperty[\"GeographicRegion\", \"Countries\"]"])]],{"ElectricityConventionalThermal","ElectricityNuclear","ElectricityTotalRenewables"}],EntityList[(Entity["world", Entity["GeographicRegion","World"], "Entity[\"GeographicRegion\", \"World\"]", "geographic region"])[(EntityProperty["countries", EntityProperty["GeographicRegion","Countries"], "EntityProperty[\"GeographicRegion\", \"Countries\"]"])]]}],FrameLabel->{"Fossil fuels","Nuclear","Renewables"},PlotStyle->Red]

Scaling: Infinite Scales

In order to make it easier to visualize the asymptotic behavior of functions, the Wolfram Language is now able to plot over infinite domains. In the following plot it is hard to tell what the long-term behavior is.

Plot[((x Sin[x]+Log[x])/(x Log[x])),{x,1,100}]

By changing the upper limit to ∞, the plot automatically uses a scaling function that compresses large values into a more manageable visual space. This helps to show that the magnitudes are trending toward zero.

Plot[((x Sin[x]+Log[x])/(x Log[x])),{x,1,Infinity}]

In this case it is possible to confirm that the function converges to zero as x goes to ∞.

Limit[((x Sin[x]+Log[x])/(x Log[x])),x->Infinity]

Infinite scales can also be specified using ScalingFunctions, which is especially useful for the range instead of the domain.

Plot[x+Sin[x],{x,-∞,∞},ScalingFunctions->"Infinite"]

Without setting ScalingFunctions, the plot would use a normal scale for the y values.

Plot[x+Sin[x],{x,-∞,∞}]

Automatic infinite scales are supported in many functions including Plot, Plot3D, ContourPlot, DensityPlot, RegionPlot, and more.

Plot3D[(1/(Sqrt[(x^2)+(y^2)])),{x,-∞,∞},{y,-∞,∞},ScalingFunctions->"Infinite",PlotRange->All]

Scaling: Date Scales

In the simplest form, TimeSeries objects will automatically use date scales when appropriate. Below we directly plot a time series of temperatures for Champaign, IL using ListLinePlot.

temp=AirTemperatureData[Here,{DateObject[{2022,1,1}],DateObject[{2022,1,7}]}]

ListLinePlot[temp]

With more cities, ListLinePlot3D can be used to create a ridgeline plot of the time series for each city, with appropriately labeled axes.

temps=AirTemperatureData[cities={LinguisticAssistant,LinguisticAssistant,LinguisticAssistant,LinguisticAssistant},{DateObject[{2022,1,1}],DateObject[{2022,1,7}]}]

ListLinePlot3D[temps,PlotLegends->cities,Filling->Bottom]

If the data is not in a TimeSeries object, the "Date" scaling function can still be used.  Here it is applied to both axes to create a date-date plot of sunrise and sunset over the course of the year.

ListLinePlot[{Table[{date,TimeObject[Sunrise[Here,date]]},{date,DateRange[(DateObject["Fri 1 Jan 2021", DateObject[{2021,1,1},"Day"]]),(DateObject["Fri 31 Dec 2021", DateObject[{2021,12,31},"Day"]])]}],Table[{date,TimeObject[Sunset[Here,date]]},{date,DateRange[(DateObject["Fri 1 Jan 2021", DateObject[{2021,1,1},"Day"]]),(DateObject["Fri 31 Dec 2021", DateObject[{2021,12,31},"Day"]])]}]},ScalingFunctions->{"Date","Date"}]

DateScale

In most cases "Date" will be sufficient to use a date scale along a particular dimension.  There is also a DateScale object that allows finer control on how to parse dates and  format tick labels.

In this example, the dates are ambiguous strings.  The DateFunction option determines exactly how the strings are interpreted.

stringdata={{"01-01",1},{"01-02",4},{"01-03",3},{"01-04",5},{"01-05",7},{"01-06",6},{"01-07",5},{"01-08",6}};

ListLinePlot[stringdata,ScalingFunctions->{DateScale[DateFunction->(DateObject[{#,{"Day","-","Month"}}]&)],None}]

Interpret the strings as month-day instead of day-month.

ListLinePlot[stringdata,ScalingFunctions->{DateScale[DateFunction->(DateObject[{#,{"Month","-","Day"}}]&)],None}]

Here, the ticks are labeled with the full month name and short day numbers.

ListLinePlot[stringdata,ScalingFunctions->{DateScale[DateFunction->(DateObject[{#,{"Month","-","Day"}}]&),DateTicksFormat->{"MonthName", " ", "DayShort"}],None}]

Plot Styling

MaterialS