[Date Index]
[Thread Index]
[Author Index]
Re: Plotting vectors on a linear function
*To*: mathgroup at smc.vnet.net
*Subject*: [mg125960] Re: Plotting vectors on a linear function
*From*: "djmpark" <djmpark at comcast.net>
*Date*: Tue, 10 Apr 2012 02:26:46 -0400 (EDT)
*Delivered-to*: l-mathgroup@mail-archive0.wolfram.com
*References*: <6915491.14834.1333964813926.JavaMail.root@m06>
This is the kind of diagram that the Presentations Application is a great
help with. You just programmatically draw one thing after another as you
would by hand. You could do this diagram with standard Mathematica but it is
much less intuitive. Here is the code in Presentations. I used red circle
points to mark the special points and, just for fun, added a Text label
within the plot.
<< Presentations`
Module[{x0 = 4/12},
(* Data based labels for the axis lines *)
xticks =
CustomTicks[Identity, databased[{x0, 1}],
CTNumberFunction -> (InputForm)];
yticks = CustomTicks[Identity, databased[{1 - x0, 1}]];
Draw2D[
{(* Linear function *)
Draw[1 - x, {x, 0, 1}],
(* Arrows attached to the linear function *)
Table[Arrow[{{x, 1 - x}, {x, 1 - x} + 1/5 {x, 1 - x}}], {x, 0, 1,
1/12}],
(* Dotted lines marking a specific point on the function *)
{Dashing[0.01],
Line[{{0, 1 - x0}, {x0, 1 - x0}, {x0, 0}}]},
(* Red circle points marking the ends and selected point *)
CirclePoint[#, 3, Black, Red] & /@ {{0, 1}, {x0, 1 - x0}, {1, 0}},
(* Text label in the plot *),
Text[Style["Diderot Diagram", 16], {0.5, 1}, {-1, 0}]},
Axes -> True, AxesLabel -> {Subscript[x, 2], Subscript[x, 1]},
PlotRange -> {{0, 1.2}, {0, 1.2}},
PlotRangePadding -> 0.05,
ImagePadding -> {{10, 20}, {20, 20}},
Ticks -> {xticks, yticks},
Method -> {"AxesInFront" -> False},
ImageSize -> 300]
]
Since two of the circle points lie on the axes and I don't want the axis
lines to cut through the point coloring I used a special Graphics Method
option to put the axes behind the graphics. I also used data based
CustomTicks to put tick marks only at specific points, and used InputForm on
the x-axis ticks for more compact labeling with fractions.
Mathematica has many special plot types but it doesn't (and couldn't) have a
GeometricDiagram plot type. You have to compose them yourselves.
David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/index.html
From: Clemens Diderot [mailto:clmnsbchn at gmail.com]
Hi all,
I am trying to plot a linear function (y=1-x) together in one graph with a
bunch of vectors, which have their tails on the function. A bit like in this
example here: http://pic.twitter.com/GRfhjPRP
Anyone any idea? Much appreciated!
Best
CD
Prev by Date:
**Re: Mathematica 8 3D Plot question**
Next by Date:
**Re: Where is ShowGraph?**
Previous by thread:
**Re: Plotting vectors on a linear function**
Next by thread:
**Re: reverses order of terms producing the string: 1.2 x=**
| |