Tag Info

Hot answers tagged

11

Bob Hanlon's answer works very well, but in some ways it is the hard way of doing things. If you have v9 or v10, then it is arguably easier to use the legend constructs within it. Similar to his answer, we get the image and element names: img = Import["ExampleData/1PPT.pdb", "Rendering" -> "BallAndStick", ImageSize -> 500]; elements = ...


10

bas = Import["ExampleData/1PPT.pdb", "Rendering" -> "BallAndStick", ImageSize -> 500]; elements = Import["ExampleData/1PPT.pdb", "ResidueAtoms"] // Flatten // Union; legend = GraphicsColumn[{ {Graphics[{#[[1]], Disk[{0, 0}, 1]}, ImageSize -> 10], #[[2]]} & /@ Thread[{ ElementData[#, "IconColor"] & /@ elements, ...


6

I suspect that ContourPlot doesn't really have a notion of the orientation of curves in a way that will let you preserve them after applying arbitrary transformations. ParametricPlot is probably the way to go. Start with parametric representations of the hyperbolas with the desired orientation: hyperbola1[t_] := {#, -#} &@{Csc[t], -Cot[t]}; ...


6

Still guessing... is the expected output something like the following? ContourPlot[{Re[(u + I v)^2] == 1, Im[(u + I v)^2] == 2, u == 1, v == 2}, {u, -4, 4}, {v, -4, 4}, Axes -> True, Frame -> False, BaseStyle -> Arrowheads[{{.05, .5}}], PlotLegends -> "Expressions", ContourStyle -> ...


6

Manipulate[ ParametricPlot3D[ {Cos[u], Sin[u] + Cos[v], Sin[v]}, {u, 0, 2 \[Pi]}, {v, -\[Pi], \[Pi]}, Mesh -> {If[uMeshOn, uMesh, 0], If[vMeshOn, vMesh, 0]}, Boxed -> boxed, Axes -> boxed, PlotStyle -> pltStyle], Row[{ Control[ {{uMesh, 15, "u Mesh"}, 0, 36, 1, Appearance -> "Labeled", ImageSize -> ...


5

Actually a very simple modification would make your approach work: Plot[Evaluate[u[4., x] /. %], {x, 0, 1}] the problem is that for pattern matching (which is what ReplaceAll (/.) does in the background) 4 (with head Integer) and 4. (with head Real) are two different things. You even might meet cases where using 4. would not be enough to make this work, ...


5

This can done with Epilog. f[x_, y_] := x^2 + 5 y^2; contours = {2, 4, 6, 8, 10, 12, 14, 16, 20}; lblXY = {#, 0} & /@ (Solve[f[x, 0] == #, x][[2, 1, 2]] & /@ contours // N); ContourPlot[f[x, y], {x, -5, 5}, {y, -2, 2}, Contours -> contours, AspectRatio -> Automatic, ContourShading -> None, Epilog -> {Thread[Text[contours, lblXY, ...


5

Kind of a hack but this is what I would do. f[x_, y_] := x^2 + 5 y^2; c = {2, 4, 6, 8, 10, 12, 14, 16, 20}; labelPos = Solve[f[x, 0] == #, x][[2, 1, 2]] & /@ c; Show[ ContourPlot[f[x, y], {x, -5, 5}, {y, -2, 2}, Contours -> c, AspectRatio -> Automatic, ContourShading -> None], Graphics[Text[#[[2]], {#[[1]], 0}, {0, 0}, Background -> ...


4

The following will do what you ask, but likely not as expediently as you hoped for. SeedRandom[42]; With[{data = RandomInteger[100, 100]}, With[{xspan = Length@data, yspan = Max@data}, DynamicModule[{mag, center, box, plotCenter}, Column[{ ClickPane[ Dynamic @ ListPlot[data, PlotRange -> box[center], ...


4

It's a function ...you need to specify one: StreamPlot[{x, -y}, {x, -1, 1}, {y, -1, 1}, StreamColorFunction -> (Yellow &)] StreamPlot[{x, -y}, {x, -1, 1}, {y, -1, 1}, StreamColorFunction -> (Red &)] StreamPlot[{x, -y}, {x, -1, 1}, {y, -1, 1}, StreamColorFunction -> (RGBColor[0, 0, 0] &)]


4

Perhaps inches = 72; Plot[Sin[x], {x, 0, 4 Pi}, ImageSize -> { 4 inches, Automatic}] If you have to use Quantity you can set the ImageSize converting inches to printer points: ImageSize -> { 72 QuantityMagnitude[Quantity[4, "Inches"]], Automatic} Update: or, better yet, Plot[Sin[x], {x, 0, 4 Pi}, PlotStyle->Thick, ImageSize -> { ...


4

You can apply a strategy I learned from @Jens. Add the following to your notebook: Map[SetOptions[#, Prolog -> {{EdgeForm[], Texture[{{{0, 0, 0, 0}}}], Polygon[#, VertexTextureCoordinates -> #] &[{{0, 0}, {1, 0}, {1, 1}}]}}] &, {ParametricPlot}]; Give your plot a name: im1 = PlotU2Treh = ParametricPlot[ ...


3

data = 14; f1[data_, x_] := x^3 - data x^2 - x + 1 Plot[f1[data, x], {x, -2, 15}, PlotStyle -> Blue, AxesLabel -> {"x", "y"}, Epilog -> {PointSize[Large], Red, Point[{x, 0} /. FindRoot[ f1[data,x], {x, -5000, 5000}]]}] Perhaps better: Plot[f1[data, x], {x, -2, 15}, PlotStyle -> Blue, AxesLabel -> {"x", "y"}, Epilog -> ...


3

The ImageSize documentation, under Details reads: "Specifications for both width and height can be any of the following: " d d printer's points (before magnification) 72di di inches (before magnification) So if you want 4 inches you can use: Plot[Sin[x], {x, 0, 4 Pi}, ImageSize -> (72 4)] for other units toPrintPoints = ...


3

Attributes[Plot] {HoldAll, Protected, ReadProtected} Since Plot has attribute HoldAll you need to use Evaluate. Also, use of Exclusions at transition values avoids gaps in the Plot f20[x_, P_, Q_, R_, S_, T_, U_] := InterpolatingPolynomial[ {{{P[[1]]}, P[[2]], 0}, {{Q[[1]]}, Q[[2]]}}, {x}]; f21[x_, P_, Q_, R_, S_, T_, U_] := ...


3

Yes another workaround Show@{ContourPlot[x^2 + 5 y^2, {x, -5, 5}, {y, -2, 2}, Contours -> Range[2, 20, 2], AspectRatio -> Automatic, ContourShading -> None, ImageSize -> 640], ContourPlot[x^2 + 5 y^2, {x, 0, 5}, {y, -0.0001, 0.0001}, Contours -> Range[2, 20, 2], ContourLabels -> (Text[#3, {#1, #2}, Background -> White] ...


3

You are supposed to use ListLinePlot for line charts since Mathematica 6, which as paw illustrated handles this correctly. The behavior of ListPlot is due to the structure of the Graphics object that is produced: g1 = ListPlot[{Table[Sin[i], {i, 25}], Table[Cos[i], {i, 25}]}, Joined -> True, PlotStyle -> {{Red, Thick, Dashed}, {Blue, Thin}}]; ...


3

LogLinearPlot[ Evaluate@Table[i[r, o], {r, {100, 200, 400, 600}}], {o, 1*10^-4, 0.1}, PlotRangePadding -> None, PlotRange -> {{1*10^-4, Automatic}, {0, 2000000}}, Filling -> Axis, Frame -> True]


2

This will do what you asked for, but -- as you can see from the plot -- your three experiments don't plot well together because the hex experiment values are incommensurable with the oct and butane experiment values. myNIR = {{ {, 2, 4, 6, 8, 9}, {hex, 342432, 435345, 564564, 56756, 9945}, {oct, 23, 356, 565, 304, 564}, {butane, 55, 67, 76, 44, 7} }} ...


2

If you accept the position of the arrowheads ... r1 /. Line -> Arrow


2

Additional controls added to facilitate exploration: Manipulate[ ParametricPlot3D[ {Cos[u], Sin[u] + Cos[v], Sin[v]}, {u, uMin, uMax}, {v, vMin, vMax}, Mesh -> { If[uMeshOn, uMesh, 0], If[vMeshOn, vMesh, 0]}, Boxed -> boxed, Axes -> boxed, PlotStyle -> pltStyle, PlotRange -> {{-1.1, 1.1}, {-2.1, 2.1}, {-1.1, ...


2

This seems to do the right thing: VectorPlot[(-efield), {x, -10, 10}, {y, -10, 10}, AspectRatio -> Automatic, VectorScale -> {Automatic, Automatic, 1/#5^2 &}] (although you might want to twiddle the scaling parameter). Notice that the scaling function is a function of five parameters, of which the norm of the gradient is the last, hence #5.


2

This is not any improvement over rm-rf. In v9 you can also use Legended: Module[{f, col = {Red, Blue}, exp, leg, pm = {\[DiamondSuit], 20}}, f[legend_] := Framed[legend, FrameStyle -> Red, RoundingRadius -> 10, FrameMargins -> 5, Background -> LightBlue]; exp = GraphicsGrid[ Partition[ Table[ListPlot[{Sqrt[Range[0, 50, 5]], ...


2

As I mentioned in a comment, the code works fine the way it is. Here's a faster way: Clear[f]; f[x_] := x; integral = NDSolveValue[{y'[x] == f[x], y[0] == 0}, y, {x, -1, 1}]; Plot[integral[x], {x, -1, 1}]


2

You could use FaceGrids Graphics3D[Cylinder[], Axes -> True, FaceGrids -> {{0, -1, 0}, {-1, 0, 0}}, Boxed -> False]


2

As Mr.Wizard indicated, you can also reconstruct the plot using the data. Here is an example: restylePlot2[p_, op : OptionsPattern[ListLinePlot]] := ListLinePlot[Cases[Normal@p, Line[x__] :> x, ∞], op, Options[p]] then we can set the style as we do in plot. For example restylePlot2[myplot2, PlotStyle -> {{Green, Thick, Dashed}, ...


2

I am not sure what you are trying to do exactly, but this works fine: ContourPlot[w[x, y, z] /. z -> int[x, y], {x, 0, 8}, {y, 0, 8}]


1

Working backward: You never gave w1 any arguments within ContourPlot (to fill its parameters). The output of z1[x, y] is not a replacement rule. The output of int[x, y] is not a replacement rule. If you give the exact series of replacement that you wish to implement I can help you accomplish it.


1

Use ParametricPlot: NDSolve[{x''[t] + x[t] == 0, x[0] == 1, x'[0] == 0}, x, {t, 0, 2 Pi}] {X[u_], XD[u_]} = {x[u], x'[u]} /. First[%] ParametricPlot[{X[t], XD[t]}, {t, 0, 2 Pi}, AxesLabel -> {x[t], x'[t]}, PlotStyle -> {Blue, Thick}]


1

As per Documentation Dashing[{}] "specifies that lines should be solid". Hence ListPlot[{Table[x, {x, 1, 10, 1}], Table[x + x^2, {x, 1, 10, 1}]}, PlotMarkers -> None, PlotRange -> All, PlotStyle -> { {Dashing[{.03, .015}], Thickness[.005], ColorData[1, 1]}, {Dashing[{}], Thickness[.0075], ColorData[1, 1]}}, Joined -> True] You have ...



Only top voted, non community-wiki answers of a minimum length are eligible