Visualization - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : System : Information : Updates : Maple 18 : updates/Maple18/Visualization

Visualization

 

 

Background Images on Plots

ColorTools Updates

Custom Plot Shading

Fractals

Signal Processing

Time Series

 

Background Images on Plots

ColorTools and Color Palettes in Maple 18

Custom Plot Shading

Extruding 2-D Plots to 3-D

Fractals

Signal Processing Visualizations

Time Series Analysis Visualizations

Background Images on Plots

Plots have several new options that make it possible to add a background image, as well as to programmatically set the plot size.

withplots:withplottools:

Example

Changing the size or background color of a plot is easily done using new options for plotting commands.

plotcosx,x=2 π..2 π,       color = red,        axis=color=white,       size=0.5,300,       background=Black

 

Example

Background images can be used to show the connection between mathematical expressions and real life structures. In this example, a parabola follows the rails of a roller coaster.

imagefileFileTools:-JoinPathkerneloptsdatadir,images","rollercoaster.jpg :displayplot3.5x122,thickness=5, color = red,             view=3..3,0..4,             axis=color=blue,             background=imagefile

 

Example

The following example plots the location of all earthquakes of magnitude 2.5 or greater over a 7 day period. Data compiled by the U.S. Geological Survey.

For more details on these new options, see the Background Images page.

ColorTools and Color Palettes in Maple 18

Several new commands in the ColorTools  package allow collections of colors (palettes) to be extended or reduced. Such collections of colors can be easily used in the shading of multiple plot objects.

 

This section illustrates the functionality by extracting the colors from an external image file, reducing the full collection of its colors to a small representative list, extending that collection with additional colors, sorting that larger collection to increase visual distinction, and then using the final collection of colors as the basis of a new plotting color palette.

 

In addition, we demonstrate a new way to visualize collections of colors.

restart:withImageTools:withColorTools:withplots:

 

We can begin by reading an image file into the Maple session. The resulting Array structure is interpreted by Maple as an image, and can be viewed or embedded directly in the current Worksheet or Document.

imgfileFileTools:-JoinPathkerneloptsdatadir,images,windturbine.jpg:

EmbedScaleImageTools:-Readimgfile,0.5

 

The colors can be extracted from the image. The ColorsFromImage command can extract from the image a list of Color  objects as a format understood by the ColorTools package.

full:=ColorsFromImageimgfile:numelemsfull

805

(2.1)

 

Below is a small selection of those colors.

full610..630

RGB : 0.722 0.75 0.738,RGB : 0.682 0.715 0.707,RGB : 0.66 0.702 0.706,RGB : 0.671 0.712 0.729,RGB : 0.689 0.723 0.735,RGB : 0.703 0.732 0.739,RGB : 0.718 0.735 0.72,RGB : 0.672 0.702 0.701,RGB : 0.54 0.564 0.442,RGB : 0.596 0.623 0.608,RGB : 0.562 0.591 0.546,RGB : 0.566 0.595 0.582,RGB : 0.509 0.517 0.317,RGB : 0.509 0.519 0.312,RGB : 0.522 0.544 0.348,RGB : 0.532 0.551 0.362,RGB : 0.56 0.577 0.391,RGB : 0.547 0.567 0.374,RGB : 0.585 0.596 0.396,RGB : 0.569 0.585 0.384,RGB : 0.566 0.578 0.369

(2.2)

 

The new SpatterPlot  and SpatterPlot3d commands of Maple 18 allow us to visualize the distribution of colors in the image in either two or three dimensions. These new commands also allow the colors to be plotted in various color spaces .

 

Here are the colors from the image, plotted in terms of the RGB and Lab color spaces.

display ArraySpatterPlot3dfull,space=RGB,SpatterPlot3dfull,space=Lab  

 

Using the ReducePalette  command, the list of colors from the image can be reduced to a much smaller, but still representative, list of colors.

reduced:=ReducePalettefull

reduced:=Lab : 69 -2.13 -7.59,Lab : 59 -1.01 -21.9,Lab : 51 0.557 -30.8,Lab : 55 -11 32.2

(2.3)

numelemsreduced

4

(2.4)

The small list of representative colors can be further expanded to produce a larger palette.

new:=ExpandPalettereduced,number=16

new:=Lab : 64.3 -41 24,Lab : 41.6 21.4 -45.7,Lab : 61 -18.4 -15.5,Lab : 51.6 -29.7 16.6,Lab : 71.7 -12.1 6.42,Lab : 49.9 1.39 25.8,Lab : 48.7 44.6 -17.4,Lab : 43.7 14.8 17.7,Lab : 65.5 -29.3 -3.19,Lab : 52.5 -21.5 -2.62,Lab : 66.1 -30.5 41.1,Lab : 40.4 31.9 -12.9,Lab : 52.4 13.1 -32.2,Lab : 57 -11.3 -21.5,Lab : 52.4 -25.9 28.3,Lab : 46.2 10.8 -38.4,Lab : 65 -34 6.49,Lab : 50.4 -15.8 -9.54,Lab : 72.1 -8.91 -1.76,Lab : 64.1 -43.8 38.2,Lab : 65.1 -11.1 5.89,Lab : 47.3 38.5 7.58,Lab : 67.3 12.6 -9.83,Lab : 66.9 -7.96 42.8,Lab : 55.1 16.9 28.2,Lab : 45.5 39.7 -39.2,Lab : 57.1 34.2 -24.5,Lab : 39.1 25.8 11.3,Lab : 60.1 5.87 34.5,Lab : 45 -5.68 -17.8,Lab : 50.4 27.8 22.2,Lab : 72 -1.52 10.7,Lab : 37.6 26.2 -29.1,Lab : 39.6 28.3 0.093,Lab : 37.8 9.25 -29,Lab : 67.4 -17.1 -9.27,Lab : 53.7 23.9 -30

(2.5)

 

The above list of colors is not ordered in a manner suitable for plotting multiple curves, since the colors near the start of the list are too close together. Notice that the first and fourth colors are not readily distinguishable.

 

The expanded list of colors can be sorted by the new SortPalette command, so that the earlier colors are farther apart. This can make the final list of colors more suitable as a palette for plotting multiple curves, since the earlier colors will be more visually distinguishable in the given color space.

final:=SortPalettenew

final:=Lab : 64.3 -41 24,Lab : 45.5 39.7 -39.2,Lab : 55.1 16.9 28.2,Lab : 57 -11.3 -21.5,Lab : 66.9 -7.96 42.8,Lab : 67.3 12.6 -9.83,Lab : 47.3 38.5 7.58,Lab : 72.1 -8.91 -1.76,Lab : 52.5 -21.5 -2.62,Lab : 37.8 9.25 -29,Lab : 52.4 -25.9 28.3,Lab : 65.5 -29.3 -3.19,Lab : 52.4 13.1 -32.2,Lab : 57.1 34.2 -24.5,Lab : 45 -5.68 -17.8,Lab : 43.7 14.8 17.7,Lab : 40.4 31.9 -12.9,Lab : 72 -1.52 10.7,Lab : 66.1 -30.5 41.1,Lab : 49.9 1.39 25.8,Lab : 39.1 25.8 11.3,Lab : 41.6 21.4 -45.7,Lab : 48.7 44.6 -17.4,Lab : 60.1 5.87 34.5,Lab : 65.1 -11.1 5.89,Lab : 50.4 27.8 22.2,Lab : 37.6 26.2 -29.1,Lab : 39.6 28.3 0.093,Lab : 67.4 -17.1 -9.27,Lab : 61 -18.4 -15.5,Lab : 51.6 -29.7 16.6,Lab : 53.7 23.9 -30,Lab : 46.2 10.8 -38.4,Lab : 65 -34 6.49,Lab : 50.4 -15.8 -9.54,Lab : 64.1 -43.8 38.2,Lab : 71.7 -12.1 6.42

(2.6)

displayseqplotxi,x=5..10,thickness=4,color=finali,i=1..5

 

To set a new color palette for plotting, pass the above final color list to the setcolors  command. This allows the colors to be used for shading multiple curves without requiring any reference to the color list within the plotting commands.

 

The Color  object is just one of several formats to denote color that the setcolors command supports.

setcolorsColorTools:-Palettefinal:

 

plotseqxi,i=1..5,x=5..10,thickness=4

Student:-Calculus1:-ApproximateIntsinx,0..π,output=plot

Student:-MultivariateCalculus:-ApproximateIntsinxsiny,x=3..3,y=3..3,z=2..2,output=plot,partition=5,5

 

The extended palette can be plotted together with the original full list of colors from the image.

SpatterPlotfull[],final[]

 

Custom Plot Shading

Custom shading schemes are now supported for three-dimensional plotting when using the plot3d command as well as for two-dimensional density-style plotting using the surfdata command. Shading can be specified using coloring procedures, color data from existing 3-D plots, or images.

Examples

Continuing the example from the ColorTools section above, we can see how 3-D plots can now be easily shaded with color gradients. In this example, this is done using the RGB color space equivalent colors from the reduced list.

 

reducedrgb:=map2Color,RGB,reduced

reducedrgb:=RGB : 0.616 0.667 0.713,RGB : 0.455 0.566 0.706,RGB : 0.329 0.485 0.681,RGB : 0.518 0.532 0.293

(3.1)

plot3d1,t=π..π,p=0..π,colorscheme=zgradient,reducedrgb,lightmodel=none,coords=spherical

A 3-D plot can also be shaded with an image, a form of texture mapping. In the following example we apply a satellite map (image courtesy of NASA Blue Marble Next Generation) to a sphere, generating a representation of the Earth as a globe.

plot3d1, t=π..π,p=0..π, image= http://www.maplesoft.com/data/examples/jpg/world.200412.400x200.jpg, lightmodel=none, coords=spherical,axes=none

Extruding 2-D Plots to 3-D

Another feature added in Maple 18 with applicability to 3-D plotting and solid modeling is the extrude command.

This takes a 2-D plot and extrudes it along a specified path. The default path is a uniform extrusion in the z-direction over the specified interval.

f  plot1 sin,sin+1,2 π..2 π: 

plotsdisplayf

(4.1)

poly:=0,1,0,2,0.5,2.75,1.25,3,2,2.75,2.5,2.25,1.75,1.5,2.5,0.75,2,0.25,1.25,0,0.5,0.25:

g plotspolygonplotpoly,axes=none,color=DarkGreen: g;

plottoolsextrudef,0..1

extrusionMap  x,y,tx+cosx+t4,y+ sinx+t4,t:

plottoolsextrudeg,0..5, extrusionMap,numsegments=10

Fractals

The new Fractals package makes it easier to create and explore popular fractals, including Mandelbrot, Julia, Newton, and other time-iterative fractals.

withFractals:-EscapeTime:

withImageTools:

M:=Mandelbrot500,2.01.35I,0.7+1.35I:

EmbedM;

For more information on the new Fractals package, see Escape-Time Fractals.

Signal Processing Visualizations

The Signal Processing package now features new commands for generating spectrograms as well as plots for signals. 

 

To find out about other new functionality for Signal Processing, see Updates in Signal Processing.

 

Example

withSignalProcessing:

dataVector28,isinevalfπi5+rand1012,datatype=float8:

SpectrogramBlackmanNuttallWindowdata,                    samplerate=50,                    includepowerspectrum,                    includesignal,                    fftsize=128,                    colorscheme=zgradient,SteelBlue,PaleGreen,red,Black,markers=0,0.5,0.8,1

 

Time Series Analysis Visualizations

The new Time Series Analysis package features several new plots, including TimeSeriesPlot, which displays time series data, and SeasonalSubseriesPlot, which displays seasonal time series data.

 

For more details on this package, see New Time Series Analysis Package.

 

Example

withTimeSeriesAnalysis:

TS1:=TimeSeries7,23,21,19,13,46,42,30,31,26,19,9,16,26,17,33,31,46,42,35,45,30,11,17,23,20,15,36,31,55,49,39,36,28,12,11,21,23,27,33,36,49,42,37,33,45,12,7,23,32,25,42,27,52,50,34,41,40,16,14,                                       frequency=monthly,startdate=2005-09

TS1:=Time seriesdata set60 rows of data:2005-09-01 - 2010-08-01

(7.1)

To display a simple plot of the Time Series, use the TimeSeriesPlot command.

TimeSeriesPlotTS1

To show seasonal Time Series data, use the SeasonalSubseriesPlot command.

SeasonalSubseriesPlotTS1

 

See Also

Connectivity

New Math Apps

Programmatic Image Embedding

What's New in Maple18