Tag Info

Hot answers tagged

17

Good way: use a higher setting of WorkingPrecision. Plot[{Exp[x]^(-2 I π) Hypergeometric2F1[-2 I π (Sqrt[2] + 1), 2 I π (Sqrt[2] - 1), 1 - 4 I π, -Exp[x]] + Exp[x]^(2 I π) Hypergeometric2F1[-2 I π (Sqrt[2] - 1), 2 I π (Sqrt[2] + 1), 1 + 4 I π, -Exp[x]]}, {x, -10, 10}, ...


17

After some spelunking it appears I have an answer and solution: the behavior is as intended, and it is controlled by a Method option "AllowMicroRanges". ListLinePlot[dat, PlotRange -> Full, Method -> {"AllowMicroRanges" -> #} ] & /@ {True, False} It seems this option may also be given directly, outside of Method, but if you wish to ...


15

The numerical evaluation of your argument function leads to very small imaginary parts in the result that are due to numerical inaccuracy. Remove them by wrapping the argument of Plot in Chop (see its documentation): Plot[Chop[(E^x)^(-2 I π) Hypergeometric2F1[-2 I π - 2 I Sqrt[2] π, -2 I π + 2 I Sqrt[2] π, 1 - 4 I π, -E^x] + (E^x)^(2 I π) ...


14

Suppose you have a set of points $S=\{a\in A:f(a)=0\}$ lying in some abstract space $A$. To visualize it, you consider a map $g:A\to\mathbb R^3$, and you wish to draw $g(S)$, the image of your set under $g$. If $g$ is invertible, this is the same as drawing the set $\{x\in\mathbb R^3:f(g^{-1}(x))=0\}$, and ContourPlot3D can do that. In your case, $A=\mathbb ...


13

You can combine parts of @Julian comment and @Szabolcs comment in the original post to have it marked automatically. f[x_] := (2^x - 2)/(x - 1) Plot[f[x], {x, -10, 10}, Exclusions -> {Reduce[! FunctionDomain[f[x], x]]}, ExclusionsStyle -> {Disk[], PointSize -> 0.015`}] The inequalities that are returned by FunctionDomain negated to get the ...


13

Update: I have realized since writing this that the below algorithm is not exactly what Plot uses anymore. Given the reference in my reference, a book written by someone who knew Mathematica very well, I guess that the algorithm has been changed in more recent versions of Mathematica. The algorithm that Plot uses is explained in the link provided by ...


13

Outwardly, the graph looks just the same as the one without ExclusionsStyle -> Dashed: f[x_] := (x^5 - 4 x^2 + 1)/(x - 1/2); g1 = Plot[f[x], {x, -1, 2}, Exclusions -> f[x] == 0] But it's surprising that ExclusionsStyle does make a difference actually. Let's check the graphs with Alexey Popkov's shortInputForm: g1 // shortInputForm g2 = ...


11

In the version 10.2, there is a builtin DensityPlot3D function, which can be used to visualize orbitals. a0=1; With[{ρ = 2 r/(n a0)}, Sqrt[(2/(n a0))^3 (n - l - 1)!/(2 n (n + l)!)] Exp[-ρ/2] ρ^ l LaguerreL[n - l - 1, 2 l + 1, ρ] SphericalHarmonicY[l, m, θ, ϕ]] DensityPlot3D[(Abs@ψ[{3, 2, 0}, {Sqrt[x^2 + y^2 + z^2], ArcTan[z, Sqrt[x^2 + ...


10

However, is there something you can put in the code to set the speed? Animate takes an option AnimationRate I still haven't been able to draw the bottom part of the first animation on https://courses.engr.illinois.edu/tam212/avt.xhtml#avt and note how it continues to move to the right (without everything jumping around). I think you can get as ...


10

Such a filling is possible with ParametricPlot. ParametricPlot[{x, x (Sin[x] + o)}, {x, 0, 4 Pi}, {o, -0.5, .5}, ColorFunction -> (ColorData["Rainbow"][#4] &), AspectRatio -> 1/GoldenRatio, Frame -> False, Axes -> False, BoundaryStyle -> None]


9

This was more involved than I expected. First, you need to set the ColorFunction to encompass the full range, ColorData[{"BlueGreenYellow", {0, 10}}] Interestingly, I did not know about that form of ColorData until earlier this week, so I recommend reading through the Details section closely. Now, to use this within ContourPlot, you need to set ...


8

I think this question has been asked before, the short answer is the function is at least not real for numerical evaluation. Table[{(E^x)^(-2 I π) Hypergeometric2F1[-2 I π - 2 I Sqrt[2] π, -2 I π + 2 I Sqrt[2] π, 1 - 4 I π, -E^x] + (E^x)^(2 I π) Hypergeometric2F1[ 2 I π - 2 I Sqrt[2] π, 2 I π + 2 I Sqrt[2] π, 1 + 4 I π, -E^x]}, {x, ...


8

Since V8.0.4 (or earlier?), we have Tooltip for 3D graphics. Here's one way via post-processing. f[x_, y_] = (x^3 + y^3)/(x^2 + y^2); plot = Plot3D[f[x, y], {x, -1, 1}, {y, -1, 1}, MeshFunctions -> {#3 &}] plot /. Line[pp_] :> Tooltip[Line[pp], plot[[1, 1, First[pp], 3]]] If you make the mesh lines thicker, they'll be a little easier to hover ...


8

Taking ilian's commentary suggestion and running with it, I found I could get a nice looking plot by tweaking some options. SeedRandom[42]; data = {RandomInteger[{2000, 5000}, 28], RandomInteger[500, 28]}; ticks = DateRange[{2011, 11}, {2014, 2}, {2, "Month"}][[All, {1, 2}]] {{2011, 11}, {2012, 1}, {2012, 3}, {2012, 5}, {2012, 7}, {2012, 9}, {2012, 11}, ...


8

First things first, you made quite a mess with your definitions. Let's straighten them a bit: bes[n_, v_, θ_, α_, u_] := BesselJ[n, v Sin@θ/Sin@α] Exp[I u Cos@θ/Sin@α^2] cs[n_, θ_] := {(1 + Cos@θ), Sin@θ , (1 - Cos@θ)}[[n +1]] Sqrt@Cos@θ Sin@θ i[n_, u_, v_, α_]:= i[n,u,v,α]= NIntegrate[cs[n, θ] bes[n, v, θ, α, u], {θ, 0, α}] ex[A_, u_, v_, α_, ϕ_] := ...


8

Cases[Quiet@{#, Abs[Subtract @@ (x /. NSolve[Sin[x] == # && -Pi <= x <= Pi, x, WorkingPrecision -> 20])]} & /@ Range[-1, 1, 2/100], {_Rational, _Real}] // ListPlot Of course you may do Plot[Abs[Subtract @@ (x /. Solve[Sin[x] == y && ...


7

The fact that your plot doesn't show "too high" values isn't specific to LogPlot, has nothing to do with the PlotRange you specified and also isn't due to the values being "too high". It is the result of the initial sampling of the plot points. According to my observations so far, no Plot includes the lower and upper limit specified for the variable. For ...


7

Thank you Michael!! I will write the answer here for other people. t[y_?NumericQ] := x /. FindRoot[g[x, y], {x, 1}] worked like charm


7

Two problems are involved here. The electric field is ill-behaved at a sharp point, and computational resolution is limited. The first can be seen by plotting the potential, uval, calculated using the code in the Question, for various values of y. Plot[Table[uval[x, y], {y, 0, .2, .02}], {x, -1, 1}, AxesLabel -> {x, u}] Notice the cusp developing ...


7

First, you used with when you should have used With and the assignments to cb,... won't work this way. Let me give you an easier alternative that uses NDSolveValue With[{σ=1.8,α=0.4,β=0.1,ρ=0.02, δ=0.05,g=-0.0029411764705882357,rr=0.017647058823529415}, dek=k'[t]==k[t]^α (r[t] s[t])^β-δ k[t]-c[t]-g k[t]; des=s'[t]==-r[t] s[t]-(-rr) s[t]; ...


6

I don't understand the "combining" part of your question, but this makes a contour plot: ListContourPlot[Flatten /@ Flatten[Transpose[{Outer[List, x, y], mat}, {3, 2, 1}], 1], Epilog -> {Red, PointSize[Medium], Point /@ Outer[List, x, y]}]] ContourPlot[ Interpolation[Flatten[Transpose[{Outer[List, x, y], mat}, {3, 2, 1}], 1]][u, v], ...


6

You can use a conditional ColorFunction within DiscretePlot to achieve what I think you want. In that case, it is important to prevent Mathematica from scaling of the values passed to the ColorFunction using ColorFunctionScaling -> False. The conditional expression used as a ColorFunction is given the $(x,y)$ values to be plotted as a Sequence. We check ...


6

This is an addendum to rcollyer's answer. I'll delete this should he choose to incorporate the gist of this answer into his. I think there are better choices to be made for the PlotLegends and ColorFunction options. Consider the following: ContourPlot[x y, {x, 0, 2}, {y, 0, 2}, PlotLegends -> BarLegend[{Automatic, {0, 4}}, {Automatic, 8}], ...


6

It appears to be a problem with the square root: f = 9 - x^2 - y^2; ContourPlot[f, {x, -4, 4}, {y, -4, 4}, Contours -> {0, 1, 4, 9}, ContourLabels -> (Text[Sqrt[#3], {#1, #2}] &), ContourShading -> None] My guess is that the algorithm used by ContourPlot implicitly relies on the function having a smooth gradient in some neighborhood of ...


6

f = Sqrt[9 - x^2 - y^2]; Reduce[f == 0, {x, y}, Reals] -3 <= x <= 3 && (y == -Sqrt[9 - x^2] || y == Sqrt[9 - x^2]) Mathematica has a hard time finding a real solution for f == 0. Using a large number of PlotPoints and forcing the result to be real using Re produces a highly segmented plot (multiple labels for 0) ...


6

It seems to me that what you want is a ContourPlot, with a strong caveat (see below). Your function is defined in polar coordinates, so in order to use ContourPlot, we need to transform to polar coordinates, as: v -> Sqrt[x^2 + y^2] phi -> ArcTan[x, y] Thus, replace any instance of v or phi in w with the corresponding expression in terms of of x and ...


6

You need the angles in radians in your data: data2 = {#[[1]]*Pi/180, #[[2]]} & /@ data; Or data2 = {#[[1]] Degree, #[[2]]} & /@ data; Then plot ListPolarPlot[data2, PolarAxes -> True, PolarTicks -> {"Degrees", Automatic}, Joined -> True, PolarGridLines -> True] UPDATE To show only part of the circle, play around with the ...


6

Your problem is that you are not fitting raw data to a distribution, you are fitting the emperical PDF of that distribution (probably in terms of values, percentages pairs). That won't work as the functions you are using (I guess EstimatedDistributionor FindDistributionParameters) expect the raw measurement data, not frequencies. To deal with your specific ...


6

We can design custom arrowheads! Define arrow = Graphics[{ FilledCurve[{ Line[{ {-1.5, 0.}, {-1.5, 0.}, {-1.95, 1.05}, {0., 0.} , {0., -1.05}, {0.15, -1.05}, {0.15, 1.05}, {0., 1.05} , {0., 0.}, {-1.95, -1.05}, {-1.5, 0.} }] }] }] Then, in your code, you can make two-headed arrows using Arrowheads[{{0.015, 1, arrow}, ...


6

I think that I stated this before in a previous post: ExclusionsStyle is a rather strange option. It works differently than other style options and the documentation on it must be read carefully. The relevant part of the documentation for this question is that concerning the style specification for the exclusion boundary points. In the OP's example, where ...



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