Visualisation des données avec Mathematicaasch/Teaching/CSLicence99/polyvisu.pdfVisualisation des...

22
Visualisation des données avec Mathematica Joachim Asch Pour une exposition plus complète consulter le livre: Mathematica par S. Wolfram , le livre Mathematica for Scientists par T.B.Bahder ou le serveur http://www.wri.com où l'on trouve les excellentes présentations de T. Wickham-Jones et autres. ü 5.1. Structure ü 5.2 Graphics en deux dimensions ü 5.2.1 Directives, primitives et Options ü 5.2.2 Coordonnées ü 5.2.3 Fonctions ü 5.3. Graphics3D ü 5.3.1 Types ü 5.3. 2 Primitives ü 5.3.3 Directives et options ü 5.3.4 Fonctions ü 5.4. Combinaisons Prolog, Epilog, Plot ....., Show ü 5.4.1Exemple (Prolog, Epilog) ü 5.4.2 Exemple (Combinaisons) ü 5.5. Labelling ü 5.5.1 Exemple Visualisation2003.nb 1

Transcript of Visualisation des données avec Mathematicaasch/Teaching/CSLicence99/polyvisu.pdfVisualisation des...

Page 1: Visualisation des données avec Mathematicaasch/Teaching/CSLicence99/polyvisu.pdfVisualisation des données avec Mathematica Joachim Asch Pour une exposition plus complète consulter

Visualisation des données avec MathematicaJoachim Asch

Pour une exposition plus complète consulter le livre: Mathematica par S. Wolfram , le livre Mathematica for Scientists par T.B.Bahder ou le serveur

http://www.wri.com où l'on trouve les excellentes présentations de T. Wickham-Jones et autres.

ü 5.1. Structure

ü 5.2 Graphics en deux dimensions

ü 5.2.1 Directives, primitives et Options

ü 5.2.2 Coordonnées

ü 5.2.3 Fonctions

ü 5.3. Graphics3D

ü 5.3.1 Types

ü 5.3. 2 Primitives

ü 5.3.3 Directives et options

ü 5.3.4 Fonctions

ü 5.4. Combinaisons

Prolog, Epilog, Plot ....., Show

ü 5.4.1Exemple (Prolog, Epilog)

ü 5.4.2 Exemple (Combinaisons)

ü 5.5. Labelling

ü 5.5.1 Exemple

Visualisation2003.nb 1

Page 2: Visualisation des données avec Mathematicaasch/Teaching/CSLicence99/polyvisu.pdfVisualisation des données avec Mathematica Joachim Asch Pour une exposition plus complète consulter

Visualisation des données avec MathematicaJoachim Asch

Pour une exposition plus complète consulter le livre: Mathematica par S. Wolfram , le livre Mathematica for Scientists par T.B.Bahder ou le serveur

http://www.wri.com où l'on trouve les excellentes présentations de T. Wickham-Jones et autres.

ü 5.1. Structure

Une expression dont la tête (Head), ou encore l'en-tête, est un objet de type graphique (Graphics, Graphics3D, SurfaceGraphics ...) admet deux

arguments:

le premier est une liste (de listes) de directives et de primitives, le deuxième une liste d'options. Pour afficher une telle expression sur l'écran on utilise

l'instruction Show.

Les graphiques sont codés en POSTSCRIPT. La traduction du code Mathematica en code Postscript est faite par Display.

Quelques fonctions de haut niveau sont prédéfinies. Par exemple pour tracer des graphes de fonctions on a Plot, Plot3D ...

ü 5.1.1 Exemple (de base)

?"Graphics"

Graphics@primitives, optionsD represents a two-dimensional graphical image.

Clear@gD;g = Graphics@[email protected], Point@80, 0<D<, 8Frame Ø True, FrameTicks Ø None<D;Show@gD;

Le code Postscript est exporté dans le fichier g.mps ( en n'oubliant pas de préciser le "chemin" sous peine de voir ce fichier sauvegardé dans un endroit

indésirable) par

chemin = "Macintosh HD:Cours Mathematica3.0LMA:";Display@chemin <> "g.mps", gD;

On lit g.mps avec

Visualisation2003.nb 1

Page 3: Visualisation des données avec Mathematicaasch/Teaching/CSLicence99/polyvisu.pdfVisualisation des données avec Mathematica Joachim Asch Pour une exposition plus complète consulter

!!Macintosh HD:Cours Mathematica3.0LMA:g.mps

%!%%Creator: Mathematica%%AspectRatio: .61803 MathPictureStart/Mabs {Mgmatrix idtransformMtmatrix dtransform} bind def/Mabsadd { Mabs3 -1 roll add3 1 roll addexch } bind def%% Graphics%%IncludeResource: font Courier%%IncludeFont: Courier/Courier findfont 10 scalefont setfont% Scaling calculations0.5 0.47619 0.309017 0.294302 [[ 0 0 -0.125 0 ][ 0 0 -0.125 0 ][ 0 .61803 .125 0 ][ 1 0 .125 0 ][ 0 0 0 0 ][ 1 .61803 0 0 ]] MathScale% Start of Graphics1 setlinecap.................

ü 5.1.2 Exemple (fonctions)

Plot@Sin@xD, 8x, 0, p<D;

0.5 1 1.5 2 2.5 3

0.2

0.4

0.6

0.8

1

InputForm@%DGraphics[ {{Line[ {{1.308996938995747*^-7, 1.3089969389957433*^-7}\, {0.12744496270371128, 0.12710024461660377}, {0.26643470259797547, 0.26329361883956875}, {0.3969696570014143, 0.38662542783721615}, {0.522504688009585, 0.49905219328635764}, {0.6561297650124452, 0.61005481218524}, {0.7847549186200374, 0.706651792186239}, {0.9214701182223191, 0.7964913872213987}, {1.0531853944293328,

Visualisation2003.nb 2

Page 4: Visualisation des données avec Mathematicaasch/Teaching/CSLicence99/polyvisu.pdfVisualisation des données avec Mathematica Joachim Asch Pour une exposition plus complète consulter

0.869003782203569}, {1.1799007472410785, 0.9245682000141244}, {1.2440493853698906, 0.9470914669312236}, {1.3147061460475136, 0.9673877276239544}, {1.3817262571763427, 0.9821794361120795}, {1.411744900137948, 0.9873779642075504}, {1.4445116214586806, 0.9920366781830787}, {1.4622674682894163, 0.994116521723827}, {1.4787518953633867, 0.9957669012179655}, {1.4958225821881594, 0.9971907850774349}, {1.5113004815484399, 0.9982306442155128}, {1.5265300961785202, 0.999020410387935}, {1.5335066890616942, 0.9993048220192023}, {1.5408772182509294, 0.999552456858429}, {1.548765610327696, 0.9997573335811045}, {1.5522683475829784, 0.9998283619033255}, {1.556023307342301, 0.9998908809326795}, {1.560062743184966, 0.9999423956444964}, {1.5638339167370445, 0.9999757625210031}, {1.566136830701334, 0.9999891445677171}, {1.568318434063113, 0.9999969300253757}, {1.5724072960740012, 0.9999987023892716}, {1.5761643040945907, 0.9999855924444514}, {1.5802143808679374, 0.9999556504565562}, {1.5840379853266646, 0.9999123305206836}, {1.5875437665208094, 0.9998597649090828}, {1.5956826433156892, 0.9996903516066877}, {1.6042515006896285, 0.9994404278644544}, {1.6126213028884657, 0.9991254631862281}, {1.620408359854478, 0.9987695754947483}, {1.638081964632778, 0.9977371753815812}, {1.6674594936298928, 0.9953317527057743}, {1.6988440127047781, 0.9918130904337064}, {1.7326308213812456, 0.9869333539597515}, {1.7692570516797244, 0.9803712234086153}, {1.835731418937394,

Visualisation2003.nb 3

Page 5: Visualisation des données avec Mathematicaasch/Teaching/CSLicence99/polyvisu.pdfVisualisation des données avec Mathematica Joachim Asch Pour une exposition plus complète consulter

0.9651094988177922}, {1.9707090243741634, 0.9210949876567722}, {2.1006867064156647, 0.8628624820872117}, {2.2256644650618975, 0.7931282460003575}, {2.35873226970282, 0.7053100250142443}, {2.4868001509484743, 0.6089946748664846}, {2.622958078188818, 0.49569473336879605}, {2.754116082033894, 0.3778532653097265}, {2.880274162483702, 0.25835450465736626}, {3.0145222889281995, 0.1267286757018376}, {3.1415925226900994, 1.3089969387348305*^-7}}\]}}, {PlotRange -> Automatic, AspectRatio -> GoldenRatio^ (-1), DisplayFunction :> $DisplayFunction, ColorOutput -> Automatic, Axes -> Automatic, AxesOrigin -> Automatic, PlotLabel -> None, AxesLabel -> None, Ticks -> Automatic, GridLines -> None, Prolog -> {}, Epilog -> {}, AxesStyle -> Automatic, Background -> Automatic, DefaultColor -> Automatic, DefaultFont :> $DefaultFont, RotateLabel -> True, Frame -> False, FrameStyle -> Automatic, FrameTicks -> Automatic, FrameLabel -> None, PlotRegion -> Automatic, ImageSize -> Automatic, TextStyle :> $TextStyle, FormatType :> $FormatType}]

ü 5.2 Graphics en deux dimensions

ü 5.2.1 Directives, primitives et Options

L'en-tête ( Head) des graphiques de dimension deux est Graphics.

On dispose d'un certain nombre de primitives comme:

?Point

Point@coordsD is a graphics primitive that represents a point.

?Line

Line@8pt1, pt2, ... <D is a graphicsprimitive which represents a line joining a sequence of points.

Visualisation2003.nb 4

Page 6: Visualisation des données avec Mathematicaasch/Teaching/CSLicence99/polyvisu.pdfVisualisation des données avec Mathematica Joachim Asch Pour une exposition plus complète consulter

ou encore: Circle, Polygon, Raster, RasterArray, Rectangle, Disk, PostScript, Text .

Les directives déterminent les détails de la représentation des primitives. Elles sont placées devant les primitives qu'elles précisent.

Les options sont des paramètres globaux du graphique concerné.

Exemples de directives: PointSize, Thickness, Dashing, AbsolutePointSize, AbsoluteThickness, Scaled, Hue, GrayLevel, RGBColor, CMYKColor .

Les options sont:

AspectRatio 1êGoldenRatio ratio of height to width

Axes False whether to draw axes

AxesLabel None axes labels

AxesOrigin Automatic where axes should cross

AxesStyle Automatic graphics directives to specify the style for axes

Background Automatic background color for the plot

ColorOutput Automatic type of color output to produce

DefaultColor Automatic the default color for plot elements

DisplayFunction $DisplayFunction function for generating output

Epilog 8< graphics primitives to be rendered after the main plot

FormatType $FormatType the default format type for text

Frame False whether to put a frame around the plot

FrameLabel None frame labels

FrameStyle Automatic graphics directives giving the style for the frame

FrameTicks Automatic frame tick marks

GridLines None grid lines to draw

ImageSize Automatic the absolute size at which to render the graphic in a notebook

PlotLabel None a label for the plot

PlotRange Automatic range of values to include

PlotRegion Automatic the final display region to be filled

Prolog 8< graphics primitives to be rendered before the main plot

RotateLabel True whether to rotate y labels on the frame

TextStyle $TextStyle the default style for text

Ticks Automatic tick marks

Exemple ( Line et Dashing)

Show@Graphics@[email protected], 0.03<D, Line@880, 0<, 81, 1<<D<, Line@880, 1<, 81, 0<<D<DD;

Exemple (Point, PointSize et GrayLevel)

Visualisation2003.nb 5

Page 7: Visualisation des données avec Mathematicaasch/Teaching/CSLicence99/polyvisu.pdfVisualisation des données avec Mathematica Joachim Asch Pour une exposition plus complète consulter

Show@Graphics@[email protected], Point@80, 0<D, [email protected], [email protected],Point@80, .5<D, [email protected], Point@80, 1<D<D, Frame Ø TrueD;

-0.4 -0.2 0 0.2 0.40

0.2

0.4

0.6

0.8

1

Show@%, PlotRange Ø 88-4, 4<, 8-4, 4<<D;

-3 -2 -1 0 1 2 3 4-4

-3

-2

-1

0

1

2

3

4

?PointSize

PointSize@dD is a graphics directive which specifies that pointswhich follow are to be shown if possible as circular regions with diameterd. The diameter d is given as a fraction of the total width of the graph.

?GrayLevel

GrayLevel@levelD is a graphics directive which specifies the gray-level intensity with which graphical objects that follow should be displayed.

The gray level must be a number between 0 and 1; 0 represents black; 1 represents white.

Exemple (Circle, Hue et RGBColor, AbsolutePointSize)

ShowAGraphicsAAppendAikjjj9HueA #1ÅÅÅÅÅÅÅ5

E, Circle@8#1, 0<, 1D= &y{zzz êü Range@5D,8RGBColor@1, 0, 0D, AbsolutePointSize@20D, Point@82, 0<D<EEE;

Visualisation2003.nb 6

Page 8: Visualisation des données avec Mathematicaasch/Teaching/CSLicence99/polyvisu.pdfVisualisation des données avec Mathematica Joachim Asch Pour une exposition plus complète consulter

AbsolutePointSize @dD is a graphics directive which specifies that points which follow are to be shown if possible as circular regions

with absolute diameter d. The absolute diameter is measured in units of printer ' s points, approximately equal to 1 ê 72 of an inch.

ü 5.2.2 Coordonnées

L'ensemble des points avec coordonnées {x,y} donné par l'utilisateur détermine le Plot Range-> {{xmin,xmax} ,{ymin,ymax} } . Cet ensemble de points est ensuite transformé ((affine)) sur l'ensemble {{0,1}, {0,As-

pect Rat io }} qui est affiché sur une partie du domaine de représentation de l'écran.

Cette partie s'appelle Plot Region. Elle est paramétrée dans un système cartésien de coordonnées {{0,0},{0,1}} qui s'appellent

Scaled[{x,y}]. Par défaut cette région est aussi grande que possible.

Enfin il y a des coordonnées Scaled[{dx,dy},{x,y}] relatives au point

{x,y} en coordonnées absolues.

Exemple (PlotRange)

Pour les fonctions graphiques le PlotRange est déterminé automatiquement

comme ensemble des points intéressants.

Clear@gD;g = Plot@Tan@xD, 8x, -p, p<D;

-3 -2 -1 1 2 3

-40

-20

20

40

Options@%, PlotRangeD8PlotRange Ø Automatic<FullOptions@%%, PlotRangeD88-3.2986722862692829, 3.2986722862692829<,8-45.91154970130959893, 47.95419599715483952<<Show@g, PlotRange Ø 88-3, 3<, 80, 10<<D;

-3 -2 -1 0 1 2 3

2

4

6

8

10

Visualisation2003.nb 7

Page 9: Visualisation des données avec Mathematicaasch/Teaching/CSLicence99/polyvisu.pdfVisualisation des données avec Mathematica Joachim Asch Pour une exposition plus complète consulter

Exemple (Scaled et PlotRegion)

Clear@gD;g = ShowAGraphicsA98AbsolutePointSize@10D, Point@80, 0<D<,9RectangleAScaled@80, 0<D, ScaledA9 1

ÅÅÅÅÅÅÅ10

, 1=EE==E, Axes Ø TrueE;

-0.4 -0.2 0.2 0.4

-0.4

-0.2

0.2

0.4

Show@g, Frame Ø True, FrameLabel Ø 8"x", "Ce texte est très long"<, RotateLabel Ø FalseD

-0.4-0.200.20.4x

-0.4-0.2

00.20.4

Ce texte est tr s long

ShowAg, PlotRegion Ø 99 1ÅÅÅÅ4,

3ÅÅÅÅ4=, 9 1

ÅÅÅÅ4,

3ÅÅÅÅ4==, Background Ø GrayLevelA 3

ÅÅÅÅ5EE

-0.4-0.2 0.2 0.4

-0.4

-0.2

0.2

0.4

Exemple (Scaled relative)

errorbar@8x_, y_<D :=8Line@[email protected], -0.04<, 8x, y<D, [email protected], -0.04<, 8x, y<D<D,Line@8Scaled@80, -0.04<, 8x, y<D, Scaled@80, 0.04<, 8x, y<D<D,Line@[email protected], 0.04<, 8x, y<D, [email protected], 0.04<, 8x, y<D<D<

Visualisation2003.nb 8

Page 10: Visualisation des données avec Mathematicaasch/Teaching/CSLicence99/polyvisu.pdfVisualisation des données avec Mathematica Joachim Asch Pour une exposition plus complète consulter

Show@Graphics@[email protected], Point@80, 0<D, errorbar@80, 0<D<DD

Exemple (AspectRatio)

Clear@gdef, g1, gautoD;gdef = Graphics@Rectangle@80, 0<, 84, 1<DD;g1 = Graphics@Rectangle@80, 0<, 84, 1<D, AspectRatio Ø 1D;gauto = Graphics@Rectangle@80, 0<, 84, 1<D, AspectRatio Ø AutomaticD;Show@GraphicsArray@8gdef, g1, gauto<DD;

Visualisation2003.nb 9

Page 11: Visualisation des données avec Mathematicaasch/Teaching/CSLicence99/polyvisu.pdfVisualisation des données avec Mathematica Joachim Asch Pour une exposition plus complète consulter

Plot@Tan@xD, 8x, 0, 2 p<, AspectRatio -> AutomaticD;

123456-40-202040

ü 5.2.3 Fonctions

Des fonctions toutes faites sont heureusement prévues dans Mathematica comme Plot, ListPlot etc. Elles retournent un objet Graphics du type décrit plus

haut ( voir l'exemple( Plot, Evaluation) ci-dessous) et affichent cet objet.

Evaluation des arguments

Dans les fonctions comme Plot les instructions définissant le premier argument ne sont pas effectuées:

Information@"HoldAll", LongForm Ø FalseDAttributes@PlotDHoldAll is an attribute which specifies that allarguments to a function are to be maintained in an unevaluated form.8HoldAll, Protected<

La demande d'évaluation est parfois inévitable:

Plot@HSin@# xD & êü Range@3DL, 8x, 0, p<DPlot::plnr : HSin@#1 xD &L êü Range@3D is not a machine-size real number at x = 1.30899693899574698`*^-7 .

Visualisation2003.nb 10

Page 12: Visualisation des données avec Mathematicaasch/Teaching/CSLicence99/polyvisu.pdfVisualisation des données avec Mathematica Joachim Asch Pour une exposition plus complète consulter

Plot@Evaluate@Sin@# xD & êü Range@3DD,8x, 0, p<, PlotStyle -> HDashing@8# .02<D & êü Range@3DLD;

0.5 1 1.5 2 2.5 3

-1

-0.5

0.5

1

et parfois très utile

fint[x_] := Integrate[Cos[y]*Exp[-y/2], {y, 0, x}]

Timing@Plot@fint@xD, 8x, 0, 5<DD êê First

1 2 3 4 5

0.2

0.4

0.6

35.2333 Second

Timing@Plot@Evaluate@fint@xDD, 8x, 0, 5<DD êê First

1 2 3 4 5

0.2

0.4

0.6

1.11667 Second

Exemple (ListPlot, plusieurs listes)

On a déjà vu la fonction Plot. Pour afficher des données discrètes on a List Plot .

Visualisation2003.nb 11

Page 13: Visualisation des données avec Mathematicaasch/Teaching/CSLicence99/polyvisu.pdfVisualisation des données avec Mathematica Joachim Asch Pour une exposition plus complète consulter

ypoints=(N[Sin[7#]Exp[-#^2]]&)/@(Range[50]3/50);Short[%,3]80.406295, 0.733997, 0.921737, á45à, 0.00017401, 0.000103252<ListPlot[ypoints];

10 20 30 40 50

-0.5

-0.25

0.25

0.5

0.75

xycouples=({N[#],N[Sin[7#]Exp[-#^2]]}&)/@(Range[50]3/50);Short[%,3]880.06, 0.406295<, 80.12, 0.733997<, á47à, 83., 0.000103252<<ListPlot@xycouplesD;

0.5 1 1.5 2 2.5 3

-0.5

-0.25

0.25

0.5

0.75

Voici une autre façon d'engendrer ces couples pour les gens encore peu familiers des fonctions pures de Mathematica:

f@x_D = N@Sin@7 xD Exp@-x^2DD; xpoints = N@3ê 50 Range@50DD;Short@Transpose@8xpoints, f@xpointsD<D, 3D880.06, 0.406295<, 80.12, 0.733997<, á47à, 83., 0.000103252<<

Toutefois l'avantage de la première méthode est qu'elle n'utilise pas d'identifca—teurs. On change maintenant la taille et la couleur des points:

Visualisation2003.nb 12

Page 14: Visualisation des données avec Mathematicaasch/Teaching/CSLicence99/polyvisu.pdfVisualisation des données avec Mathematica Joachim Asch Pour une exposition plus complète consulter

ListPlot[xycouples,PlotStyle->{AbsolutePointSize[4],GrayLevel[1/2]}];

0.5 1 1.5 2 2.5 3

-0.5

-0.25

0.25

0.5

0.75

Le problème de la représentation de plusieurs listes dans un seul graphique est plus difficile que pour les fonctions:

xyCoscouples=({N[#],N[Cos[7#]Exp[-#^2]]}&)/@(Range[50]3/50);

gS=ListPlot[xycouples,DisplayFunction->Identity,PlotStyle->{AbsolutePointSize[4],GrayLevel[1/2]}];gC=ListPlot[xyCoscouples,DisplayFunction->Identity;Show[{gS,gC},DisplayFunction->$DisplayFunction];

0.5 1 1.5 2 2.5 3

-0.75

-0.5

-0.25

0.25

0.5

0.75

Exemple (ParametricPlot)

ParametricPlot@8Sin@tD, Sin@2 tD<, 8t, 0, 2 Pi<D;

-1 -0.5 0.5 1

-1

-0.5

0.5

1

Exemple (Plot, Echantillonage)

Mathematica a une façon sophistiquée d'échantillonner. Soit:

Visualisation2003.nb 13

Page 15: Visualisation des données avec Mathematicaasch/Teaching/CSLicence99/polyvisu.pdfVisualisation des données avec Mathematica Joachim Asch Pour une exposition plus complète consulter

Clear@gD; g = Plot@Sin@xD, 8x, 0, Pi<D;

0.5 1 1.5 2 2.5 3

0.2

0.4

0.6

0.8

1

Comment connaître les points qui ont été calculés?8Short@g@@1DDD, Short@g@@2DDD<888Line@á1àD<<, 8PlotRange Ø Automatic, á23à, FormatType ß $FormatType<<Comme on le voit, et comme on l'a annoncé au début de ce chapitre, le résultat est donné sous la forme d'un objet Graphics avec comme premier argument

une liste de primitives et comme deuxième argument une liste d'options. Le premier argument est la ligne brisée représentant le graphe. Pour accéder à la

liste de points il faut donc demander

Short@g@@1, 1, 1, 1DD, 5D881.309µ 10-7, 1.309µ 10-7<, 80.127445, 0.1271<,á50à, 83.01452, 0.126729<, 83.14159, 1.309 µ 10-7<<

On dessine maintenant la projection des sommets de cette ligne brisée sur l'axe des x:

p@8x_, y_<D = 8x, 0<;ListPlot@Map@p, g@@1, 1, 1, 1DDD, Axes -> NoneD;

ü 5.3. Graphics3D

ü 5.3.1 Types

Pour des objets à trois coordonnées il y a le type Graphics3 D. Pour les graphes des fonctions de deux variables il y a en outre les types

SurfaceGraphics, DensityGraphics, ContourGraphics .

Visualisation2003.nb 14

Page 16: Visualisation des données avec Mathematicaasch/Teaching/CSLicence99/polyvisu.pdfVisualisation des données avec Mathematica Joachim Asch Pour une exposition plus complète consulter

ü 5.3. 2 Primitives

Cuboid, Point, Text, Line, Polygon

Exemple: Cuboid, Point, Line, text

ShowAGraphics3DA9CuboidA80, 0, 0<, 9 1ÅÅÅÅ4,

1ÅÅÅÅ4,

1ÅÅÅÅ4=E, Point@81, 1, 1<D,

Line@880, 0, 0<, 81, 1, 1<<D, TextA"Intérieur", 9 1ÅÅÅÅ2,

1ÅÅÅÅ2,

1ÅÅÅÅ2=E=EE;

Int rieur

Exemple (Polygon)

Clear@randtriangD;randtriang := Polygon@Table@8Random@D, Random@D, Random@D<, 83<DD;Show@Graphics3D@Table@randriang, 85<DDD

Visualisation2003.nb 15

Page 17: Visualisation des données avec Mathematicaasch/Teaching/CSLicence99/polyvisu.pdfVisualisation des données avec Mathematica Joachim Asch Pour une exposition plus complète consulter

ü 5.3.3 Directives et options

On dispose en plus des directives des graphiques à deux dimensions de: FaceForm, EdgeForm,SurfaceColor

Options@Graphics3DD8AmbientLight Ø [email protected], AspectRatio Ø Automatic, Axes Ø False,AxesEdge Ø Automatic, AxesLabel Ø None, AxesStyle Ø Automatic,Background Ø Automatic, Boxed Ø True, BoxRatios Ø Automatic, BoxStyle Ø Automatic,ColorOutput Ø Automatic, DefaultColor Ø Automatic, Epilog Ø 8<, FaceGrids Ø None,Lighting Ø True, LightSources Ø 8881., 0., 1.<, RGBColor@1, 0, 0D<,881., 1., 1.<, RGBColor@0, 1, 0D<, 880., 1., 1.<, RGBColor@0, 0, 1D<<,PlotLabel Ø None, PlotRange Ø Automatic, PlotRegion Ø Automatic,Plot3Matrix Ø Automatic, PolygonIntersections Ø True, Prolog Ø 8<,RenderAll Ø True, Shading Ø True, SphericalRegion Ø False, Ticks Ø Automatic,ViewCenter Ø Automatic, ViewPoint Ø 81.3, -2.4, 2.<, ViewVertical Ø 80., 0., 1.<,DefaultFont ß $DefaultFont, DisplayFunction ß $DisplayFunction<

Exemple (FaceForm, ViewPoint)

?FaceForm

FaceForm@gf, gbD is a three-dimensional graphicsdirective which specifies that the front faces of polygons are tobe drawn with the graphics primitive gf, and the back faces with gb.

Show@GraphicsArray@8Graphics3D@8FaceForm@GrayLevel@0D, [email protected],

Polygon@880, 0, 0<, 81, 0, 0<, 80, 1, 0<<D<,Lighting Ø FalseD,

Graphics3D@8FaceForm@GrayLevel@0D, [email protected],Polygon@880, 0, 0<, 81, 0, 0<, 80, 1, 0<<D<,

ViewPoint Ø 81.3, -2.4, -2<,Lighting Ø FalseD< DD;

Visualisation2003.nb 16

Page 18: Visualisation des données avec Mathematicaasch/Teaching/CSLicence99/polyvisu.pdfVisualisation des données avec Mathematica Joachim Asch Pour une exposition plus complète consulter

?Lighting

Lighting is an option for Graphics3D and related functions thatspecifies whether to use simulated illumination in three-dimensional pictures.

?LightSources

LightSources is an option for Graphics3D and related functions thatspecifies the properties of point light sources for simulated illumination.

The option LightSources gives the positions and intensities of point light sources.

Options@Graphics3D, LightSourcesD8LightSources Ø 8881., 0., 1.<, RGBColor@1, 0, 0D<,881., 1., 1.<, RGBColor@0, 1, 0D<, 880., 1., 1.<, RGBColor@0, 0, 1D<<<ü 5.3.4 Fonctions

Plot3D, ParametricPlot3D, DensityPlot, ContourPlot,ListPlot3D, ListDensityPlot, ListContourPlot

Exemple (Plot3D, Contour, Density,ParametricPlot3D)

f@0, 0D = 0; f@x_, y_D =x2 - y2ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅx2 + y2

;

Clear@gp, gc, gdD;gp = Plot3D@f@x, yD, 8x, -1, 1<, 8y, -1, 1<,

PlotPoints Ø 30, DisplayFunction Ø Identity, Mesh Ø FalseD;gc = ContourPlot@f@x, yD, 8x, -1, 1<, 8y, -1, 1<,

Contours Ø 40, DisplayFunction Ø IdentityD;gd = DensityPlot@f@x, yD, 8x, -1, 1<, 8y, -1, 1<,

PlotPoints Ø 40, DisplayFunction Ø IdentityD;Show@GraphicsArray@8gp, gc, gd<D, DisplayFunction Ø $DisplayFunctionD;

-1-0.5 00.5

1-1-0.500.51

-1-0.500.51

10.5 00.5

-1-0.5 0 0.5 1-1

-0.5

0

0.5

1

-1-0.5 0 0.5 1-1

-0.5

0

0.5

1

On obtient le même résultats par des conversions qui ne coûtent rien:

Show@ContourGraphics@gpD, DisplayFunction Ø $DisplayFunctionD

-1-0.5 0 0.5 1-1

-0.5

0

0.5

1

Ü ContourGraphics Ü

Visualisation2003.nb 17

Page 19: Visualisation des données avec Mathematicaasch/Teaching/CSLicence99/polyvisu.pdfVisualisation des données avec Mathematica Joachim Asch Pour une exposition plus complète consulter

ParametricPlot3D@8t, u Cos@tD, u Sin@tD<,8t, 0, 2 p<, 8u, -1, 1<, Boxed Ø False, Axes Ø FalseD;

ParametricPlot3DA9t, u Cos@tD, u Sin@tD, GrayLevelA1 -t

ÅÅÅÅÅÅÅÅ2 p

E=,8t, 0, 2 p<, 8u, -1, 1<, Boxed Ø False, Axes Ø False, Lighting Ø FalseE;

ü 5.4. Combinaisons

Prolog, Epilog, Plot ....., Show

ü 5.4.1Exemple (Prolog, Epilog)

funct@x_D = ExpA-x

ÅÅÅÅÅÅÅ10

E - Cos@30 xD Exp@-3 xD;court = Plot@funct@xD, 8x, 0, 1<, Frame Ø TrueD;

0 0.2 0.4 0.6 0.8 10

0.25

0.5

0.75

1

1.25

1.5

1.75

Visualisation2003.nb 18

Page 20: Visualisation des données avec Mathematicaasch/Teaching/CSLicence99/polyvisu.pdfVisualisation des données avec Mathematica Joachim Asch Pour une exposition plus complète consulter

Plot@funct@xD, 8x, 0, 50<, Frame Ø True, Prolog Ø Rectangle@818, .5<, 848, 1.2<, courtD,Epilog Ø Text@"Long and short times", 815, 1.3<DD;

0 10 20 30 40 500

0.2

0.4

0.6

0.8

1

1.2

1.4

0 0.20.40.60.8 10

0.250.5

0.751

1.251.5

1.75Long and short times

?Epilog

Epilog is an option for graphics functions which gives a list of graphicsprimitives to be rendered after the main part of the graphics is rendered.

ü 5.4.2 Exemple (Combinaisons)

p1 = Plot3D@x2 - y2, 8x, -1, 1<, 8y, -1, 1<,BoxRatios Ø 81, 1, 2<, DisplayFunction -> IdentityD;

p2 = Plot3D@y2 - x2, 8x, -1, 1<, 8y, -1, 1<, BoxRatios Ø 81, 1, 2<,DisplayFunction -> IdentityD;

Show@GraphicsArray@8p1, p2<DD;-1-0.500.51

-1-0.5

00.51

-1

-0.5

0

0.5

110.500.5

-1-0.500.51-1-0.5

00.51

-1

-0.5

0

0.5

110.500.5

Ü GraphicsArray Ü

Visualisation2003.nb 19

Page 21: Visualisation des données avec Mathematicaasch/Teaching/CSLicence99/polyvisu.pdfVisualisation des données avec Mathematica Joachim Asch Pour une exposition plus complète consulter

Show@p1, p2, DisplayFunction -> $DisplayFunctionD-1-0.5 0 0.5 1

-1-0.5

00.5

1

-1

-0.5

0

0.5

11-0.5

00.5

Ü Graphics3D Ü

On remarque le changement dans le type du graphique. p1 et p2 sont de type:8p1@@0DD, p2@@0DD<8SurfaceGraphics, SurfaceGraphics<ü 5.5. Labelling

ü 5.5.1 Exemple

aplot = Plot@8Cos@xD, Sin@xD<, 8x, 0, 10<,PlotStyle Ø [email protected], [email protected], 0.03<D<,[email protected], 0.03<D, [email protected]<<D;

2 4 6 8 10

-1

-0.5

0.5

1

Visualisation2003.nb 20

Page 22: Visualisation des données avec Mathematicaasch/Teaching/CSLicence99/polyvisu.pdfVisualisation des données avec Mathematica Joachim Asch Pour une exposition plus complète consulter

Show@aplot, AxesLabel Ø 8"x-Axis", "y-Axis"<, PlotLabel Ø "TrigPlot"D;

2 4 6 8 10x-Axis

TrigPlot

-1

-0.5

0.5

1

y-Axis

Show@%, DefaultFont Ø 8"Helvetica-Oblique", 18<D;

2 4 6 8 10x-Axis

TrigPlot

-1-0.5

0.51

y-Axis

Visualisation2003.nb 21