Related
I am trying to plot 2 figures that both share identical legends in a grid in Mathematical. Here is an example of the code:
Grid[{{Plot[{x + 1, 2 x + 1}, {x, 0, 10},
PlotStyle -> {{RGBColor[0.880722, 0.611041, 0.142051],
Dashed}, {RGBColor[0.880722, 0.611041, 0.142051], colors}},
PlotLegends -> {a, b}, ImageSize -> 400]},
{Plot[{-x + 10, -2 x + 10}, {x, 0, 10},
PlotStyle -> {{RGBColor[0.880722, 0.611041, 0.142051],
Dashed}, {RGBColor[0.880722, 0.611041, 0.142051], colors}},
PlotLegends -> {a, b}, ImageSize -> 400]}}]
I want to only have one legend, instead of two yet I can't find a clean way to do it with legend since there is a dashed line.
Also added ImagePadding to align the y axes.
Legended[
Grid[{{Plot[{x + 1, 2 x + 1}, {x, 0, 10},
PlotStyle -> {{RGBColor[0.880722, 0.611041, 0.142051],
Dashed}, {RGBColor[0.880722, 0.611041, 0.142051], colors}},
ImageSize -> 400,
ImagePadding -> {{14, Automatic}, {Automatic, Automatic}}]},
{Plot[{-x + 10, -2 x + 10}, {x, 0, 10},
PlotStyle -> {{RGBColor[0.880722, 0.611041, 0.142051],
Dashed}, {RGBColor[0.880722, 0.611041, 0.142051], colors}},
ImageSize -> 400,
ImagePadding -> {{14, Automatic}, {Automatic, Automatic}}]}}],
Placed[LineLegend[{{RGBColor[0.880722, 0.611041, 0.142051],
Dashed}, RGBColor[0.880722, 0.611041, 0.142051]}, {a, b}], Below]]
I would like to have a means to plot a solid in R^3 using RegionPlot3D and view it from a specified point on one of the axes so that the remaining axes appear in a specified manner. For example, suppose I wish to view the plane x+y+z=1 from the point (0,0,5) in such a way that the positive x-axis points to the right and the positive y-axis points up. The problem I have is with the labelling of axes.
What I've tried:
RegionPlot3D[0 <= z && z <= 1 - x - y && 0 <= y <= 1 - x , {x, 0, 1}, {y, 0, 1}, {z, 0, 1},
Mesh -> All, PlotPoints -> 100, AxesLabel -> Automatic, LabelStyle -> Directive[Black, 12],
ViewPoint -> {0, 0, 5}, ViewAngle -> 0 Degree, PlotStyle -> Green]
The resulting green "triangle" looks like it should when viewed from the positive z-axis, but none of the axes are labeled.
RegionPlot3D[0 <= z && z <= 1 - x - y && 0 <= y <= 1 - x,
{x, 0, 1}, {y, 0, 1}, {z, 0, 1},
ViewPoint -> {0, 0, 5}, PlotStyle -> Green,
AxesEdge -> {{-1, 1}, {-1, 1}, None},
AxesLabel -> Automatic]
Equilibrium solution for y'=3-2y is at y=3/2 and I would like to add the line y=3/2 to direction field plotted using VectorPlot function. How to do?
The additional code below does it.
points = {{0, 0}, {1, 0}, {2, 0}, {0, 1}, {1, 1}, {2, 1}, {0, 2}, {1,
2}, {2, 2}};
datplot =
VectorPlot[{1, 3 - 2 y}, {x, 0, 2}, {y, 0, 2},
VectorPoints -> points, VectorScale -> {Automatic, Automatic, None},
Epilog -> {Red, PointSize[Medium], Point[points]}];
fitplot = Plot[y = 3/2, {y, 0, 2}];
{Show[datplot, fitplot]}
Mary A. Marion
Change
Epilog -> {Red, PointSize[Medium], Point[points]}
to
Epilog -> {Red, PointSize[Medium], Point[points], Line[{{0,3/2},{2,3/2}}]}
The following code will compute the solution*:
points = {{0, 0}, {1, 0}, {2, 0}, {0, 1}, {1, 1}, {2, 1},
{0, 2}, {1,2}, {2, 2}};
datplot =
VectorPlot[{1, 3 - 2 y}, {x, 0, 2}, {y, 0, 2},
VectorPoints -> points, VectorScale -> {Automatic, Automatic, None},
Epilog -> {Red, PointSize[Medium], Point[points],
Line[{{0, 3/2}, {2, 3/2}}]}]
See Bill's input above.
Currently I am trying to graph the sin(x) function and a function named myPolys which is the taylor polynomial of sin(x) as it is equal to
myPolys =
Table[Table[(-1)^((j - 1)/2) x^j/Factorial[j], {j, 1, h, 2}], {h, 1,
19, 2}];
How can I use manipulate to graph both functions so that each part of myPolys is graphed
My graphing code so far:
Manipulate[Plot[{Sin[x], myPolys[[n]]}, {x, -10, 10},
PlotRange -> {-5, 5}], {n, 1, Length[myPolys], 1}];
currently for each iteration of n, myPolys is graphed as separate
x and then x & -(x^3)/3! and then x & -(x^3)/3! & x^5/5! (all are plotted separate o the same graph )
The graph I'm trying to achieve is that for n=1 sin(x) should be plotted and x from myPoly should be plotted, for n=2 it continues and graphs x-(x^3/3!) (instead of plotting, for n=2, x and -x^3/3! seperately) and so on and so forth until n reaches 10.
My graph at the moment:
The graph I'm hoping for:
myPolys = Table[Sum[(-1)^((j - 1)/2) x^j/Factorial[j],
{j, 1, h, 2}], {h, 1, 19, 2}];
Manipulate[Plot[{Sin[x], Evaluate#Take[myPolys, n]},
{x, -10, 10}, PlotRange -> {-5, 5}], {n, 1, Length[myPolys], 1}]
Or, in more functional style.
Clear[myPolys]
myPolys[n_] := Table[Sum[(-1)^((j - 1)/2) x^j/Factorial[j],
{j, 1, h, 2}], {h, 1, 2 n - 1, 2}]
Manipulate[Plot[{Sin[x], Evaluate#myPolys[n]},
{x, -10, 10}, PlotRange -> {-5, 5}], {n, 1, 10, 1}]
And with legend.
myLabels[n_] := Table[Sum[(-1)^((j - 1)/2) x^j/ToString[j] <> "!",
{j, 1, h, 2}], {h, 1, 2 n - 1, 2}]
Manipulate[Plot[{Sin[x], Evaluate#myPolys[n]},
{x, -10, 10}, PlotRange -> {-5, 5},
PlotLegends -> Placed[PointLegend[
Rest#Array[ColorData[97], n + 1], HoldForm /# myLabels[n],
LegendMarkers -> {"\[Tilde]", 30}], Left]], {n, 1, 10, 1}]
I suppose you know there is the built in Series you can use..
Manipulate[m = n;
Show[{
Plot[Sin[x], {x, -10, 10}, PlotRange -> {-5, 5},
PlotStyle -> {Thick, Red}],
Plot[Evaluate[
Accumulate[List ## Normal#Series[Sin[x], {x, 0, m}]]], {x, -10, 10}]}],
{{n, 3}, 3, 25, 2}]
I have a data such as list of points x,y,z. I added interpolation by splines as
f = Interpolation[{#[[1 ;; 2]], #[[3]]} & /# data, Method -> "Spline"]
And after all I try to plot
`Show[Plot3D[f[x, y], {x, 10000, 10000000}, {y, 10, 50}, Mesh -> 15,
MeshFunctions -> {#3 &}, PlotRange -> {0, 0.0011},
PlotRangePadding -> {0.001, 0.0003}, PlotStyle -> Opacity[0.7],
ColorFunction -> "Rainbow",
AxesStyle -> {Black, Black, Black}],
Graphics3D[{Red, PointSize[.016], Point[data]}]]`
Can't post image.
I use such data as
data = {{10000, 10, 0.000000208191701}, {10000, 20, 0.000000416383402}, {10000, 30, 0.00000066886188}, {10000, 40,0.000000832854501}, {10000, 50, 0.000001040870809}, {100000, 10,0.000002081829313}, {100000, 20, 0.000004163483234}, {100000, 30,0.000006245400245}, {100000, 40, 0.000008327229558}, {100000, 50,0.000010409058871}, {1000000, 10, 0.000020818731618}, {1000000,20, 0.000041636761666}, {1000000, 30,
0.000062455405588}, {1000000, 40, 0.00008327361103}, {1000000, 50,
0.000104092254952},{10000000, 10, 0.000208475750285}, {10000000,
20, 0.000416951237469}, {10000000, 30,
0.000625426900044}, {10000000, 40, 0.000833902387228}, {10000000,
50, 0.001042377962108}}
And I have the question, how can I pull the graph in the Z axis by setting of other step of plotting?
I have changed the aspect ratio from the default, and added z-axis tick values.
You could simply use Ticks -> {Automatic, Automatic, {0, 0.0002, 0.0004, 0.0006, 0.0008, 0.001}} but I added some formatting. FindDivisions is useful for less straightforward cases.
Show[Plot3D[f[x, y], {x, 10000, 10000000}, {y, 10, 50}, Mesh -> 15,
MeshFunctions -> {#3 &}, PlotRange -> {0, 0.0011},
PlotRangePadding -> {0.001, 0.0003}, PlotStyle -> Opacity[0.7],
ColorFunction -> "Rainbow", AxesStyle -> {Black, Black, Black},
Ticks -> {Automatic, Automatic,
{#, NumberForm[#, {3, 4}]} & /# N#FindDivisions[{0, 0.001}, 5]},
AspectRatio -> 1, ImageSize -> 300],
Graphics3D[{Red, PointSize[.016], Point[data]}]]
Edit
Adding sub-ticks:-
Show[Plot3D[f[x, y], {x, 10000, 10000000}, {y, 10, 50}, Mesh -> 15,
MeshFunctions -> {#3 &}, PlotRange -> {0, 0.0011},
PlotRangePadding -> {0.001, 0.0003}, PlotStyle -> Opacity[0.7],
ColorFunction -> "Rainbow", AxesStyle -> {Black, Black, Black},
Ticks -> {Automatic, Automatic,
DeleteCases[
Flatten[{{#1, NumberForm[#1, {3, 4}]}, {#2, ""}, {#3, ""}, {#4, ""}} & ###
Partition[N#FindDivisions[{0, 0.001}, 20], 4, 4, {1, 1}, Null], 1],
{Null, _}]},
AspectRatio -> 1, ImageSize -> 300],
Graphics3D[{Red, PointSize[.016], Point[data]}]]
Adding Box Ratios
Show[Plot3D[f[x, y], {x, 10000, 10000000}, {y, 10, 50}, Mesh -> 15,
MeshFunctions -> {#3 &}, PlotRange -> {0, 0.0011},
PlotRangePadding -> {0.001, 0.0003}, PlotStyle -> Opacity[0.7],
ColorFunction -> "Rainbow", AxesStyle -> {Black, Black, Black},
Ticks -> {Automatic, Automatic,
DeleteCases[
Flatten[{{#1, NumberForm[#1, {3, 4}]}, {#2, ""}, {#3, ""}, {#4, ""}} & ###
Partition[N#FindDivisions[{0, 0.001}, 20], 4, 4, {1, 1}, Null], 1],
{Null, _}]}, AspectRatio -> 1, ImageSize -> 1200],
Graphics3D[{Red, PointSize[.016], Point[data]}],
BoxRatios -> {1, 1, 3},
BaseStyle -> FontSize -> 36]