Tag Info

Hot answers tagged

10

You're running into two issues. We'll start with the one that is causing the messages. By default Plot avoids symbolic evaluation of your function, and uses numeric evaluation instead. For example, it may evaluate at t=1.23: D[D[z[1.23],1.23],1.23] and then D complains that 1.23 isn't a valid variable and returns D[D[{1, 1.5129, 1.8608669999999998}, ...


8

Show[Plot[1/(x^2), {x, 0, 4}, PlotStyle -> Blue, AspectRatio -> 1], Plot[1, {x, 0, 1}, FillingStyle -> Purple, Filling -> Bottom, PlotStyle -> Blue], Plot[1/(x^2), {x, 1, 4}, PlotStyle -> Blue, Filling -> Axis, FillingStyle -> Red, PlotRange -> {Full, {0, 1}}]]


8

One easy way is to replace the style of the specific nodes in the final tree. Let's make a function for it: colorize[tree_, nodes_List] := With[{patt = Alternatives @@ nodes}, tree /. Framed[p : patt, style_, r2___] :> Framed[p, style /. c_RGBColor :> Darker[c], r2] ] Now you can do t = Plotting[S, u, d, 4]; colorize[t, {S, d^2 S*u^2, d^3 ...


7

1. If you need to change just the tick labels you can use FrameTicks as follows: rp1 = Module[{n = 300, p = 0.29}, RegionPlot[{y > (1/2)*(n - x) && y + x <= n && y > p/(1 - p)*x}, {x, 0, n}, {y, n, 0}, FrameLabel -> {"x", "y"}, PlotStyle -> {Directive[Yellow, Opacity[0.5]]}, FrameTicks -> {{{#, ToString[300 - ...


7

One Plot can do too: Plot[{If[x < 1, 1/(x^2)], If[x > 1, 1/(x^2)]}, {x, 0, 4}, AspectRatio -> 1, Filling -> {2 -> {Axis, Red}}, Epilog -> {Purple, Rectangle[]}]


6

Another variation, using ConditionalExpression: Plot[{ ConditionalExpression[x^-2, x <= 1], ConditionalExpression[x^-2, x > 1], ConditionalExpression[1, x <= 1]} , {x, 0, 4}, PlotStyle -> Blue, Filling -> {2 -> {Axis, Red}, 3 -> {Axis, Purple}}]


5

Here is a very simple, step-by-step way to go about solving your problem. z[t_] := {1, t^2, t^3} Norm[z[t]] Sqrt[1 + Abs[t]^4 + Abs[t]^6] Those absolute values are going to give us trouble, so lets get rid of them. You want to plot over the range 0 to 5, so we can assume t ≥ 0. nz[t_] = Simplify[Norm[z[t]], Assumptions -> t >= 0] Sqrt[1 + ...


5

One way would be by using PointLegend: ListPlot[Range[10], PlotMarkers -> {\[FilledCircle]}, PlotLegends -> Placed[PointLegend[{Red, Green}, Style[#, FontSize -> 20] & /@ {"A", "B"}], {Top, Right}], PlotStyle -> {Black}, Joined -> True, Mesh -> All, MeshStyle -> Red]


5

You could set up a dynamic VertexRenderingFunction that allows you to change the colors of your vertices with a click. colorClickVRF[colors_List] := Function[{pos, name}, Module[{i, len}, i = 1; len = Length[colors]; DynamicModule[{ backColor = Lighter[First[colors]], frameColor = Darker[First[colors]]}, ...


5

The built-in ContourPlot3D seems fast enough for me: f = #3 Sin[10 #1]^2 + (1 - #3) #3 Cos[20 #2]^2 &; frange = Through@{NMinValue, NMaxValue}[{f[x, y, z], 0 <= x <= 1 && 0 <= y <= 1 && 0 <= z <= 1}, {x, y, z}]; AbsoluteTiming[ trigplot3d = ContourPlot3D[x + y + z == 1, {x, 0, 1}, {y, ...


4

What you see is Moiré pattern Closely related topic with 2D case: Using high RasterSize changes contour pattern Worth to add that the patterns does not seem to have a translation symmetry because the projection is not parallel. You can compare it with distant ViewPoint case: ListPointPlot3D[ Table[{n, s, (Prime[n]^s/(Prime[n]^s - 1))}, {n, 1, 2000}, {s, ...


4

Here's some sample data along the lines of what I think you're using: {data1, data2, data3, data4, data5} = Table[{#, i} & /@ RandomVariate[NormalDistribution[i, i], 100], {i, 5}]; Now when we generate a 3D histogram with 10 bins, we get gaps: Histogram3D[{data1, data2, data3, data4, data5}, 10] The reason for this is that your bin ...


3

Make the width 1: f[{{xmin_, xmax_}, {ymin_, ymax_}, {zmin_, zmax_}}, ___] := Cuboid[{xmin, ymin, zmin}, {xmax, ymin + 1, zmax}]; Histogram3D[N@{Data1, Data2, Data3, Data4, Data5}, 10, Boxed -> False, FaceGrids -> {Bottom, Front, Left}, ChartStyle -> "Pastel", ChartElementFunction -> f, Ticks -> {Automatic, None, Automatic}, ...


3

Significant manual cleaning was required for block of data in post. The data: data = {{{"ID", "Day", 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16., 17., 18., 19., 20., 21., 22.}, {"H. sapiens", 1., 145.7, 153.2, 164.6, 161.1, 170.8, 191.7, 179.2, 178.5, 198.5, 169.9, 135.8, 182.8, 205.3, 210.3, 197.3, 238.4, ...


3

I don't think this is entirely unexpected since PlotLegends is meant to depict what the colours mean. You switch off the colours and the plot legend disappears. The canonical way to leave the "example" in place is to use an epilog: p = ContourPlot[Cos[x] + Cos[y], {x, 0, 4 Pi}, {y, 0, 4 Pi}, ContourShading -> None, Epilog -> Text["example", ...


2

While the order of the plots in Show makes difference, it is not the whole story. By default, many options are set automatically at the time of execution. In particular, PlotRange and AxesOrigin. The settings for Plot and ListPlot are determined separately since they are evaluated separately. This much I think can be inferred from the documentation, ...


2

Let me give a workaround myself after some attempts. It is only a workaround thus other answers are appreciated! ContourPlot[Cos[x] + Cos[y], {x, 0, 4 Pi}, {y, 0, 4 Pi}, PlotLegends -> Placed["example", {0.8, 0.1}], ColorFunction -> (White &)] This works. In other words, here the contour shading is not turned off, but instead colored as ...


2

As a warm up, let's find the PDF of XX. Now if we just do PDF[XX, x], Mathematica will seemingly spin forever, which one might think is caused by Integrate. Let's see if that's correct. First let's Print each time we Integrate: Block[{Integrate}, Integrate[e__] /; (Print[{e}]; False) := Null; PDF[XX, x] ] Ok so there is one integral, and notice we ...


1

Your code can be made to work as you expect to by simplifying it. With[{imgSize = 300, nPts = 100}, Manipulate[ Grid[{ {k, Cos[1. k], ""}, {p, y = Cos[p], Sin[y]}, {Graphics[{ {Gray, Line[RandomReal[{-1, 1}, {nPts, 2}]]}, {Red, Disk[p, 0.05]}}, PlotRange -> {{-1, 1}, {-1, 1}}, ImageSize ...


1

If you meant Sin[x], then I suppose something like Plot[Evaluate[Sin[x[t]] /. solution], {t, 0, 20}] is what you're after. In this case, the term "product" should be read as "composition." If, on the other hand, you meant to multiply the solution by Sin[t], then perhaps Plot[Evaluate[Sin[t] x[t] /. solution], {t, 0, 20}] will do. (Evaluate has to ...


1

reorgdata = GatherBy[data[[1]], #[[2]] &][[2 ;;, All, 3 ;;]]; variances = Thread[Variance /@ reorgdata]; means = Thread[Mean /@ reorgdata]; Row[{ListPlot[means, PlotLabel -> "means", ImageSize -> 300], ListPlot[variances, PlotLabel -> "variances", ImageSize -> 300]}]


1

The plots you are producing by adding PlotLegends all have Head of Legended. So the closest to what you already have would be to do the following: Legended[ ContourPlot[ Cos[x]+Cos[y],{x,0,4 Pi},{y,0,4 Pi}, ContourShading->None ], Placed["example",{0.8,0.1}] ] This produces an output that is of the same type as your plot with contour shading ...


1

Another workaround is to create the plot as normal and then delete all the Polygon expressions: ContourPlot[Cos[x] + Cos[y], {x, 0, 4 Pi}, {y, 0, 4 Pi}, PlotLegends -> Placed["example", {0.8, 0.1}]] // DeleteCases[#, _Polygon, -1] &



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