Re: Hatched shading?
- To: mathgroup at smc.vnet.net
- Subject: [mg111028] Re: Hatched shading?
- From: "David Park" <djmpark at comcast.net>
- Date: Sat, 17 Jul 2010 08:17:18 -0400 (EDT)
Here is a solution with Presentations. There are many elements to the plot so it's a little detailed. I think it is better to have a complete single input description of the graphic, than to make a partial plot and then use DrawingTools. What would happen if you had to change the function? The graphic might be better and simpler to make if you used color Filling instead of hatching. Filling is a little less "busy" and distracting. Hatching was a device to overcome limitations in print media. The limitations mostly don't exist anymore. So here is the filling solution first. Needs["Presentations`Master`"] f[x_] := 1/x; Draw2D[ {(* Draw the curve with a fill *) Draw[f[x], {x, 1, 5}, AxesOrigin -> {0, 0}, Filling -> Axis, FillingStyle -> Blend[{Orange, White}, .6]], (* Draw the boundary lines *) AbsoluteThickness[2], Line[{{1, 0}, {1, 1.1 f[1]}}], Line[{{5, 0}, {5, 1.1 f[1]}}], Line[{{.9, 0}, {5.1, 0}}], (* Add the labels and point *) Text[Style["Boundary Condition", 14, Bold], {.8, .5}, {0, 0}, {0, 1}], Text[Style["Boundary Condition", 14, Bold], {5.2, .5}, {0, 0}, {0, 1}], Text[Style["Initial Condition", 14, Bold], {3, -0.1}, {0, 0}], Text[Style["Solution Known", 14], {3, 0.15}, {0, 0}], Text[Style["\[CapitalGamma]", 14], {1.5, f[1.5]}, {-3, 0}], AbsoluteThickness[1], CirclePoint[{3.5, f[3.5]}, 3, Black, Green], Text[Style["P", 14, Bold], {3.5, f[3.5]}, 1.5 {-1, -1}]}, AspectRatio -> .6, PlotRange -> {{.5, 5.5}, {-.25, 1}}, PlotRangePadding -> {.1, .05}, Frame -> False, ImageSize -> 400] Here is the graphic using hatching. We supply a Table of lines using a RegionFunction to limit their extent. It is necessary to specify PlotRange or Mathematica does not always obey the RegionFunction! f[x_] := 1/x; Draw2D[ {(* Draw the hatch lines first *) Table[ Draw[.5 x - x0, {x, -1.5, 5}, RegionFunction -> Function[{x, y}, 1 < x < 5 \[And] 0 <= y <= f[x]], PlotRange -> {{1, 5}, {0, 1}}, PlotStyle -> Directive[AbsoluteThickness[3], LightGray]], {x0, -1, 5, .075}], (* Draw the curve without a fill *) Draw[f[x], {x, 1, 5}], (* Draw the boundary lines *) AbsoluteThickness[2], Line[{{1, 0}, {1, 1.1 f[1]}}], Line[{{5, 0}, {5, 1.1 f[1]}}], Line[{{.9, 0}, {5.1, 0}}], (* Add the labels and point *) Text[Style["Boundary Condition", 14, Bold], {.8, .5}, {0, 0}, {0, 1}], Text[Style["Boundary Condition", 14, Bold], {5.2, .5}, {0, 0}, {0, 1}], Text[Style["Initial Condition", 14, Bold], {3, -0.1}, {0, 0}], Text[Style["Solution Known", 14], {3, 0.15}, {0, 0}], Text[Style["\[CapitalGamma]", 14], {1.5, f[1.5]}, {-3, 0}], AbsoluteThickness[1], CirclePoint[{3.5, f[3.5]}, 3, Black, Green], Text[Style["P", 14, Bold], {3.5, f[3.5]}, 1.5 {-1, -1}]}, AspectRatio -> .6, PlotRange -> {{.5, 5.5}, {-.25, 1}}, PlotRangePadding -> {.1, .05}, Frame -> False, ImageSize -> 400] David Park djmpark at comcast.net http://home.comcast.net/~djmpark/ From: Alex [mailto:abudovski at gmail.com] Is it possible to plot something like this in Mathematica? http://img682.imageshack.us/img682/1638/hatched.png How might I do the hatched shading, with customizable colors/thickness?