Re: Graphing template
- To: mathgroup at smc.vnet.net
- Subject: [mg131352] Re: Graphing template
- From: "djmpark" <djmpark at comcast.net>
- Date: Mon, 1 Jul 2013 05:46:38 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- Delivered-to: l-mathgroup@wolfram.com
- Delivered-to: mathgroup-outx@smc.vnet.net
- Delivered-to: mathgroup-newsendx@smc.vnet.net
- References: <1161738.36984.1372407488033.JavaMail.root@m06>
This is a very nice piece of coding and on my Mathematica 9 the arrowheads ARE the same color as the function curves. Nevertheless, I am wondering why you are programming a new graphics template as a plotting interface. It is something that many people try, and I've spent some of my own time on such efforts, but unless one has a quite frequent and very restricted application (such as daily weather plots, or daily stock price charts) it is generally not worth the effort. The reason is that graphical solutions are just too varied and particular to the information being presented. Any substitute template would end up being as complex as the Mathematica graphics programming already is. Better to just get better at regular Mathematica graphics. There are several aspects of the graphics that your template produces that I might mildly criticize. It is a shame that Plot and similar commands produce an Axis plot by default. Frame plots are generally much better, especially if the curves appear in more than the first quadrant. In such cases the axes with their ticks and labels stomp all over the curves. If you look in good technical journals you will very seldom find Axis plots in such cases. A second problem is that the grid lines are much too prominent. Dashing them only makes them more prominent. Better to make them something like GrayLevel[0.9]. Here is a modified template that uses a Frame and a lighter Grid. Interpretation[{f = {1/(x - 1), Sin[x], -x, x}, points = {{3, 2}, {-5, -8}}, min = -10, max = 10, size = 0.5, rmin = -10, rmax = 10, gridx = 1, gridy = 1, hlabel = "x", vlabel = "y"}, Panel[Grid[{{Style["Plot Characteristics", Bold], SpanFromLeft}, {"Functions:", InputField[Dynamic[f]]}, {"Points:", InputField[Dynamic[points]]}, {"Domain Min:", InputField[Dynamic[min]]}, {"Domain Max:", InputField[Dynamic[max]]}, {"Range Min:", InputField[Dynamic[rmin]]}, {"Range Max:", InputField[Dynamic[rmax]]}, {"Grid Size (cm):", InputField[Dynamic[size]]}, {"Gridline Space x:", InputField[Dynamic[gridx]]}, {"Grdiline Space y:", InputField[Dynamic[gridy]]}, {"Horizontal Label:", InputField[Dynamic[hlabel]]}, {"Vertical Label:", InputField[Dynamic[vlabel]]}}]], Plot[f, {x, min - 0.58*gridx, max + 0.58*gridx}, PlotRange -> {rmin - 1.01*gridy, rmax + 1.01 gridy}, GridLines -> {Range[min, max, gridx], Range[rmin, rmax, gridy]}, GridLinesStyle -> {{GrayLevel[0.9]}, {GrayLevel[0.9]}}, Axes -> False, Frame -> True, FrameTicks -> {Range[min, max, 2 gridx], Range[rmin, rmax, 2 gridy], None, None}, TicksStyle -> Directive[10, Opacity[0], FontOpacity -> 0.9999, CMYKColor[0, 0, 0, 1], FontFamily -> "Helvetica"], ImageSize -> {(max + gridx - (min - gridx))*28.52*size + 37.2 + 6.4*StringLength[hlabel], (rmax + gridy - (rmin - gridy))*28.52* size + 49}, AspectRatio -> Full, FrameLabel -> {Style[hlabel, Italic], Style[vlabel, Italic]}, LabelStyle -> {{FontFamily -> "Helvetica", FontSize -> 14}}, AxesStyle -> {CMYKColor[1, 1, 1, 1], AbsoluteThickness[0.5]}, PlotStyle -> {{AbsoluteThickness[1], CMYKColor[0, 0, 0, 1]}, {AbsoluteThickness[1], CMYKColor[0, 0.83, 1, 0]}, {AbsoluteThickness[1], CMYKColor[1, 0, 0, 0]}, {AbsoluteThickness[1], CMYKColor[0.36, 1, 0, 0]}, {AbsoluteThickness[1], CMYKColor[0.63, 0, 1, 0]}, {AbsoluteThickness[1], CMYKColor[0, 0, 0, 1]}}, Epilog -> {(*Arrowheads[{0.04,0.01,{0,0.03}}],Arrow[{{max+gridx/2, 0},{max+gridx/2+gridx/10,0}}],Arrow[{{min-gridx/2,0},{min-gridx/ 2-gridx/10,0}}],Arrow[{{0,rmax+gridy},{0,rmax+gridy+gridy/10}}], Arrow[{{0,rmin-gridy},{0,rmin-gridy-gridy/10}}],*) AbsolutePointSize[5], Point[points]}] /. Line[x__] :> Sequence[Arrowheads[{-.04, .04}], Arrow[x]]] But even here I broke the template by uncoupling the frame label spacing and the grid spacing because the frame labels seem to me to be too dense and cluttered. Wouldn't you say that the curves and points, the important information, now stand out more clearly? Finally, there is one other aspect here that breaks the template. We might prefer that the return line on the function 1/(x-1) be eliminated. There are several ways to do this, the most common being the use of an Exclusions option (but only for that function) and there is just no way to fit this into the template without some major template expansion. That's the problem you will run into. You will keep working on the template instead of making great new graphics. David Park djmpark at comcast.net http://home.comcast.net/~djmpark/index.html From: keystonethewizard at gmail.com [mailto:keystonethewizard at gmail.com] Hi, sorry if this showed up earlier, having some problems today. I'm trying to set up a graphing template and am having trouble getting the arrowheads on the functions to match the colour of the functions themselves. The last line is my arrowheads. ClearAll["Global`*"]; Interpretation[{f = { 1/(x - 1), Sin[x], -x, x}, points = {{3, 2}, {-5, -8}}, min = -10, max = 10, size = 0.5, rmin = -10, rmax = 10, gridx = 1, gridy = 1, hlabel = "x", vlabel = "y"}, Panel[Grid[{{Style["Plot Characteristics", Bold], SpanFromLeft}, {"Functions:", InputField[Dynamic[f]]}, {"Points:", InputField[Dynamic[points]]}, {"Domain Min:", InputField[Dynamic[min]]}, {"Domain Max:", InputField[Dynamic[max]]}, {"Range Min:", InputField[Dynamic[rmin]]}, {"Range Max:", InputField[Dynamic[rmax]]}, {"Grid Size (cm):", InputField[Dynamic[size]]}, {"Gridline Space x:", InputField[Dynamic[gridx]]}, {"Grdiline Space y:", InputField[Dynamic[gridy]]}, {"Horizontal Label:", InputField[Dynamic[hlabel]]}, {"Vertical Label:", InputField[Dynamic[vlabel]]} }]], Plot[f, {x, min - 0.58*gridx, max + 0.58*gridx}, PlotRange -> {rmin - 1.01*gridy, rmax + 1.01 gridy} , GridLines -> {Range[min, max, gridx], Range[rmin, rmax, gridy]}, GridLinesStyle -> {{Dashed, CMYKColor[0, 0, 0, 1, 0.25], AbsoluteThickness[0.5]}, {Dashed, CMYKColor[0, 0, 0, 1, 0.25], AbsoluteThickness[0.5]}}, Ticks -> {Range[min, max, gridx], Range[rmin, rmax, gridy]}, TicksStyle -> Directive[10, Opacity[0], FontOpacity -> 0.9999, CMYKColor[0, 0, 0, 1], FontFamily -> "Helvetica"], ImageSize -> {(max + gridx - (min - gridx))*28.52*size + 37.2 + 6.4*StringLength[hlabel], (rmax + gridy - (rmin - gridy))*28.52* size + 49}, AspectRatio -> Full, AxesLabel -> {Style[hlabel, Italic], Style[vlabel, Italic]}, LabelStyle -> {{FontFamily -> "Helvetica", FontSize -> 14}}, AxesStyle -> {CMYKColor[1, 1, 1, 1], AbsoluteThickness[0.5]}, PlotStyle -> {{AbsoluteThickness[1], CMYKColor[0, 0, 0, 1]}, {AbsoluteThickness[1], CMYKColor[0, 0.83, 1, 0]}, {AbsoluteThickness[1], CMYKColor[1, 0, 0, 0]}, {AbsoluteThickness[1], CMYKColor[0.36, 1, 0, 0]}, {AbsoluteThickness[1], CMYKColor[0.63, 0, 1, 0]}, {AbsoluteThickness[1], CMYKColor[0, 0, 0, 1]}}, Epilog -> {Arrowheads[{0.04, 0.01, {0, 0.03}}], Arrow[{{max + gridx/2, 0}, {max + gridx/2 + gridx/10, 0}}], Arrow[{{min - gridx/2, 0}, {min - gridx/2 - gridx/10, 0}}], Arrow[{{0, rmax + gridy}, {0, rmax + gridy + gridy/10}}], Arrow[{{0, rmin - gridy}, {0, rmin - gridy - gridy/10}}], AbsolutePointSize[5], Point[points]} ] /. Line[x__] :> Sequence[Arrowheads[{-.04, .04}], Arrow[x]] ]