Hot answers tagged

9

This is very similar to Quantum_Oli's answer, but I will post it anyway. It use's a modified version of Jens's plotGrid function to do the work of combining the plots. The function is imported from a pastebin to save space here, << "http://pastebin.com/raw/tmMYLyMh"; hist = Show[ Plot[140 PDF[SmoothKernelDistribution[#], x] & /@ {data1, ...


8

Histogram does not support a grouped ChartLayout. Hence the workaround using BarChart: I've arranged the 'histogram' into a bar chart so that the data can be displayed side by side. An alternative to using BarChart with "Grouped" layout is to use a custom ChartElementFunction to produce the desired Histogram layout: ClearAll[groupedHistogram] ...


7

It is indeed possible, although not necessarily straightforward. The method I present below gives a pretty robust and accurate way of lining up plots, the downside is a little bit of code and having to specify a few different options. I'm used to it, it works. The key is that by specifying the ImageSize, and the Left and Right components of the ImagePadding ...


7

You can always impose this constraint with the option RegionFunction: PolarPlot[Sin[θ] Cos[θ], {θ, 0, 2π}] PolarPlot[Sin[θ] Cos[θ], {θ, 0, 2π}, RegionFunction -> Function[{x, y, θ, r}, r > 0]]


7

You can do something like this, SetAttributes[verbosePlot, HoldAll] verbosePlot[plotcommand_] := Module[{plot, pp, mr}, {pp, mr} = {PlotPoints, MaxRecursion} /. (Trace[plot = plotcommand, HoldPattern[(MaxRecursion -> _Integer) | (PlotPoints -> _Integer)], TraceInternal -> True] // Flatten // Reverse // ...


7

The following is a universal solution which extracts RGB color values assigned to the Line primitives of a plot generated by built-in plotting functions of Mathematica 10: Cases[fplot, {___, c_Directive, __Line} :> ColorConvert[c, RGBColor], Infinity] // InputForm {RGBColor[0.368417, 0.506779, 0.709798, 1.], RGBColor[0.880722, 0.611041, 0.142051, ...


7

Rather than Show, you can use Prolog + Inset with Scaled: Plot[ 140 PDF[SmoothKernelDistribution[#], x] & /@ {S086, T086, X086}, {x, 0, 100}, Evaluated -> True, PlotStyle -> { {Thickness[0.01], RGBColor[0.23, 0.42, 0.63]}, {Thickness[0.01], RGBColor[0.29, 0.53, 0.80]}, {Thickness[0.01], RGBColor[0.62, 0.73, 0.88]}}, Frame -> ...


6

There are numerous ways to do this in Mathematica, and it's hard to say which would be most useful for learning. Here's one; a unit circle is drawn, then a polygon with no filling and black edge on basis of CirclePoints which generates points of a regular polygon lying on the unit circle. Finally, mean of two first points is taken, and distance to the origin ...


6

I'm not sure what kinds of calculations you'll want to do on the intersection line; but to get a sample of points on the intersection line, you could use DiscretizeRegion and MeshCoordinates: f[x_, y_, z_] = x^4 + y^4 + z^4 - 1; g[x_, y_, z_] = x - 2 y + z - 2; ContourPlot3D[{f[x, y, z] == 0, g[x, y, z] == 0}, {x, -2, 2}, {y, -2, 2}, {z, -2, 2}, ...


5

ScalingFunctions works for Plot, but I had to tweak the ticks by hand: ClearAll[sfn, isfn]; SetAttributes[sfn, Listable]; SetAttributes[isfn, Listable]; sfn[x_] := Piecewise[{{x, x < 30}, {30 + Log[x] - Log[30], x >= 30}}]; isfn[y_] := Piecewise[{{y, y < 30}, {30 E^(-30 + y), y >= 30}}]; Plot[ Sin[2 Log[x]], {x, 1, 10^4}, ScalingFunctions ...


5

PolarPlot purposely accepts negative radii values as well as angles beyond the range 0 to 2$\pi$. See, for example, the PolarPlot documentation here showing PolarPlot[Sin[3 t], {t, 0, Pi}], which returns this three lobe structure including values below the x-axis (even though the plot angles are only in the range 0 to Pi). Since any real value of ...


5

Here's a possibility. Copy the graphic into a new cell, type p1 = in front of the plot and evaluate the cell. Then, do p1 /. Point[a__] :> {PointSize[0.2], Point[a]} Here's a gif showing the procedure:


4

There is no LogRegionPlot or LogLogRegionPlot, so if you want to make one you'll have to do the scaling yourself, and then supply the correct tick marks yourself using the undocumented (and sometimes poorly behaved) Charting`ScaledTicks function: {RegionPlot[Exp[Abs[x]] <= y <= 100, {x, -6, 6}, {y, 0, 120}], RegionPlot[ Log@Exp[Abs[x]] <= y ...


4

You haven't defined the x-Axis value for the ListLogLinearPlot and therefore the peak-position is dependent of the duration, which is proportional to the number of values. If you define the frequencies correctly it works well: (*Create Signal*) freq = 10000; sampleFreq = 400000; maxFreq = sampleFreq/2; dt = 1/sampleFreq; duration = 0.1; Sig[duration_, dt_, ...


4

If you look at the FullForm of your variable result you will see that it contains some small complex numbers. You can remove these by using Plot[Abs[result[[i]]] instead.


4

Use a Graph with directed edges labels = Thread[ Range[12] -> (Placed[#, Above] & /@ Join[{Subscript[x, 0]}, Range[10], {Subscript[x, f]}])]; Graph[# \[DirectedEdge] # + 1 & /@ Range[11], VertexCoordinates -> d0, VertexLabels -> labels, VertexStyle -> {1 -> Red, 12 -> Blue}] Or, if you need to have it look like the ...


4

For version 9: f[x_, y_, z_] := x^3 + y^2 - z^2 g[x_, y_, z_] := x^2 + y^2 + z^2 - 1 cp3d = ContourPlot3D[{f[x, y, z]==0, g[x, y, z]==0}, {x, -2, 2}, {y, -2, 2}, {z, -2, 2}, BoundaryStyle -> {1 -> None, 2 -> None, {1, 2} -> {Thick, Red}}, ContourStyle -> Opacity[.7], Mesh -> None, ImageSize -> 400]; points = Cases[Normal@cp3d, ...


4

This version works: rl = {ρ[z_, ϕ_] :> 1/5 Sqrt[25 - 25 z^2 + 10 Sin[5 ϕ] + Sin[5 ϕ]^2]}; Manipulate[PolarPlot[Evaluate[ReplaceAll[ρ[z, ϕ], %]], {ϕ,0, 2 Pi}], {z, -1, 1}] Manipulate[PolarPlot[Evaluate[ReplaceAll[ρ[z, ϕ], rl]], {ϕ,0, 2 Pi}], {z, -1, 1}] The main change is in the way the rule is defined as a $RuleDelayed$ instead of $Rule$.


3

ContourPlot3D[ {x^2 + y^2 == 1, z == Sqrt[x^2 + y^2]}, {x, -2, 2}, {y, -2, 2}, {z, -.5, 2}, ContourStyle -> Opacity[.65]]


3

Perhaps this is helpful or can be adapted. Using the data from OP. Note the "normal distribution" has been scaled for effect (not quantitative): d = {data1, data2, data3}; style = {Red, Green, Blue}; lab = {"data1", "data2", "data3"}; dc = DistributionChart[Join[Table[Null, {3}], d], ChartStyle -> style]; bw = BoxWhiskerChart[d, ChartStyle -> style]; ...


3

If your plot doesn't show anything, it's often helpful to look what your plotted function does. If you evaluate e.g. f[1] in your notebook, you'll see: -1 + ln[1] That's because there is no build-in function called ln. You probably want Log.


3

One way is to force temp1 and temp2 to share an endpoint: plot1 = ParametricPlot[Evaluate[l1[t] = BezierFunction[ temp1 = RandomReal[{0, RandomReal[50]}, {3, 2}]][t]], {t, 0, 3}]; plot2 = ParametricPlot[Evaluate[l2[t] = BezierFunction[ temp2 = RandomReal[{0, RandomReal[50]}, {3, 2}]; temp2[[1]] = temp1[[1]]; temp2][t]], {t, 0, 3}, ...


3

Tweak the plot domain so that it's not symmetric: ContourPlot3D[..., {α1, 0 + 0.1 + 0.0001, 90 - 0.1}, (* slight offset *) {α2, 0 + 0.1, 90 - 0.1}, {ψ, 0.2, 180 - 0.2}, ...]


3

r3 = AppendTo[Table[{Graphics[{Text[ Which[i == 1, Subscript[P, 0], i == Length[d0], Subscript[P, f], True, ToString[i - 1]], Offset[{0, 10}, d0[[i]]]]}], Graphics[{PointSize[Large], Which[i == 1, Red], Which[i == Length[d0] - 1, {Point[d0[[i]]], Blue, Point[d0[[i + 1]]]}, True, Point[d0[[i]]]]}], Graphics[{Arrow[d0[[i ;; i + ...


3

f[x_] := x + 2; g[x_] := Sin[x]; Plot[{f[x], g[x]}, {x, 0, Pi/2}, PlotRange -> {-0.1, 3.65}, PlotLegends -> "Expressions", Filling -> (1 -> {2}), Frame -> True, Epilog -> {Directive[Thick, Magenta], Line[{{#, g[#]}, {#, f[#]}}] & /@ {0, Pi/2}}] rgn = ImplicitRegion[g[x] <= y <= f[x] && 0 <= x <= ...


3

First off, in your code sol = RSolve[{x[n + 1] == 2.8*x[n]*(1 - x[n]), x[0] == 0.2}, x[n], n] ListPlot[Table[{n, x[n] /. sol[[1]]}, {n, 1, 5}], PlotStyle -> {Hue[1], PointSize[0.0125]}]; you have a semicolon after the ListPlot command, so you won't get a plot. Second, have a look at the output of RSolve - it does not give an analytic formula. sol = ...


3

ClearAll[pw] conds = # <= t <= #2 & @@@ Partition[t /@ Range[-1, 3], 2, 1]; vals = X[#][t] & /@ Range[0, 3]; pw[k_][t_] := Simplify[Piecewise[{{vals[[k + 2]], conds[[k + 2]]}}]] Plot[Evaluate[pw[#][t] & /@ Range[-1, m - 1]], {t, 0, 4}, PlotLegends -> "Expressions", PlotRange -> All]


3

Here are two additional approaches, one uses RegionIntersection, the other uses DiscretizeGraphics: f[x_, y_, z_] = x^4 + y^4 + z^4 - 1; g[x_, y_, z_] = x - 2 y + z - 2; regF = ImplicitRegion[f[x, y, z] == 0, {x, y, z}]; regG = ImplicitRegion[g[x, y, z] == 0, {x, y, z}]; reg = DiscretizeRegion @ RegionIntersection[regF, regG] MeshCoordinates @ reg // ...


3

Well, you can use DiscretizeGraphics and RandomPoint to achieve what you want: P0 = ContourPlot3D[Φeff == E0, {x, -rm, rm}, {y, -rm, rm}, {z, -rm, rm}, Mesh -> None, Lighting -> None]; Note the Lighting -> None option, this is to circumvent a bug in DiscretizeGraphics that the good people at Wolfram refuse to fix. gg = ...


2

I think it may be more expedient to use Framed to generate the frame you want, rather than having an extra graphics object: Framed[ Show[ { Graphics[{Red, Thick, Circle[]}], Plot[Sin[x], {x, -2, 5}, PlotStyle -> Directive[Thick, Blue]] }, PlotRange -> {{0, Pi}, {-Pi/2, Pi/2}}, (*REMOVED*) (*PlotRangeClipping -> ...



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