Hot answers tagged

25

Normally Plot uses machine precision numbers; your $x^x$ expression is hitting the limit of the numbers that can be represented in machine precision right about $x>143$. Note: Solve[$MaxMachineNumber == x^x, x] (* Out: {{x -> 143.016}} *) You can increase the WorkingPrecision setting for Plot adequately, and the plot will be complete: f[x_] = ...


23

Source of the problem (possibly) Here is a clear indication that your Fortran library and the Mathematica function are behaving in fundamentally different ways. I noticed the apparent high frequency oscillations in the difference functional, so I decided to see exactly how quickly they oscillate, Plot[funcfortran[w, 0.06, -1.0, 1.0, 1.0, N[π/2], 2.0, 3., ...


17

You seem to be re-evaluating the eigenvalues at every point. Just use this definition: Clear[Eval,kx, ky, kz]; Eval[kx_, ky_, kz_] = FullSimplify[ Eigenvalues[H[kx, ky, kz] + Subscript[H, 1][kx, ky, kz]]]; Then the plots will be faster. This will symbolically evaluate the eigenvalues once, and the variables kx, ky, kz get substituted into the ...


15

I don't think there is a special ribbon function. But you can plot one pretty easily. Here's an example. The functions x[u] and y[u] define a curve in space and then z[s] gives it width. x[u_] := Sin[u] u^2 y[u_] := 2 Cos[u] + u^2 z[s_] := s ParametricPlot3D[{x[u], y[u], z[s]}, {u, 0, 6}, {s, -2, 2}, Boxed -> False, Axes -> False] Here's ...


12

Your code shows you are somewhat confused about the indices. Here is some code that is more Mathematica idiomatic and which makes keeping the indices straight much easier. I am running the simulation with a 24 hour step to cut down the data plotted. Should work just a well with your time step. maxk = 10; mink = 2; steps = 365; batterylevel = ...


12

r = N @ ImplicitRegion[ Sin[x Pi] > 0 || Sin[y Pi] > 0, {{x, 0, 9}, {y, 0, 9}} ] RegionPlot @ r r3 = N @ ImplicitRegion[ Sin[x Pi] > 0 || Sin[y Pi] > 0 || Sin[z Pi] > 0, {{x, 0, 9}, {y, 0, 9}, {z, 0, 9}} ] RegionPlot3D[r3, PlotStyle -> Opacity@.5] So you can play with translation and scaling with: Sin[2 x Pi] > 0 ...


11

You can use ListPolarPlot. data = {{1, 4, 5, 2}, {3, 5, 1, 1}}; cat = {"A", "B", "C", "D"}; a = Subdivide[2*Pi, Length[cat]]; ListPolarPlot[ Transpose[{a, Flatten[{#, First@#}]}] & /@ data, Joined -> True, PolarAxes -> True, PolarTicks -> {Transpose[{Most@a, cat}], Automatic}, PolarGridLines -> Automatic] The only extra bit ...


11

This approach splits each data set in to a set of curves and then attempts to join curves whose end and start points are "close enough". The measure I have used is okay for the example data and it includes an element of rescaling with the curve data but YMMV with "real" data. It is simpler than some of the linked approaches. Firstly we use a helper ...


11

Example plot: Plot[{Cos[x], Sin[x], Tan[x]}, {x, 0, 2 π}] Now, just copy this plot from the notebook (using ctrl-C) and paste it in the front of following expression: /. a : RGBColor[__] :> ColorConvert[a, "Grayscale"] The result:


10

I was thinking along the same lines as Hubble07, but I don't care for the way the tick labels get rotated. Rotate[NumberLinePlot[x^3 < Sin[13 x], x], π/2] So you can use this, verticalNumberLinePlot[pred__] := Rotate[ NumberLinePlot[ pred, Ticks -> {Function[{min, max}, N@Join[{#, Rotate[#, -π/2], {.01, 0}} & /@ ...


10

Hunting through the stylesheets is effective, but does not necessarily give you the current value being used if it has been modified. Instead, use CurrentValue[{StyleDefinitions , "GraphicsAxes"}] (* {Arrowheads -> {}, LineColor -> GrayLevel[0.4], Thickness -> Absolute[0.2]} *) CurrentValue[{StyleDefinitions , "GraphicsFrame"}] (* {LineColor -> ...


9

Here is an idea based on graphics primitives instead of mathematical inequalities. columnWidth = 1; regionSize = 10; holes = Table[ Rectangle[{x, y}, {x + columnWidth, y + columnWidth}], {x, columnWidth, regionSize, 2 columnWidth}, {y, columnWidth, regionSize, 2 columnWidth} ]; holes // Graphics Now we subtract these squares from a larger ...


9

Use Reduce to get the region as inequalities: f[x_] := Sin[4 x] + x; Reduce[-1 <= f[x] <= 1, x, Reals] (* Root[{1 + Sin[4 #1] + #1 &, -1.45320652256538767403}] <= x <= Root[{1 + Sin[4 #1] + #1 &, -0.71249223361378546370}] || Root[{1 + Sin[4 #1] + #1 &, -0.222621770186095002502}] <= x <= Root[{-1 + Sin[4 #1] + #1 &, ...


9

I don't know how to do this in an automated way, but here is something at least: Make your plot, extract the lines, convert them to regions, and then take the RegionDifference between them plot = ContourPlot[x*Exp[-x^2 - y^2], {x, 0, 3}, {y, -3, 3}, PlotRange -> {0, 0.5}, ColorFunction -> "Rainbow"] points = Cases[Normal@plot, Line[pts__] -> ...


9

We can use the following approach: start with an end point that belongs to a path and increment the path with nearest neighbor points that are "good candidates." A point is a "good candidate" if it is not too far away from the last point and it does not produce a sharp turn in the path. To determine "too far" we a look at the distances between the last, say, ...


9

As David G. Stork has pointed out, Nearest Neighbours offer a good method of attack for this problem. Here I've not implemented a full NN chain approach but something a little more basic which gets most of the way there. I'm using a 'dumb' NN but with a distance function that only allows points to be connected to another point one x-distance away, this ...


8

As march predicted in a comment above, the noise in the plots is a precision issue. A small improvement can be obtained by setting c to a rational number, c = 4/300 and applying FullSimplify to y[x, t]. before plotting. Nonetheless, even at t = 0, the solution is quite noisy. To illustrate, compare the initial condition on u with y[x, 0]. p0 = ...


8

Normal[# /. a : Arrow[{__List}, Except[_List]] :> Thread @ a] gives a quick fix for these examples.


8

In the absence of your data, I'll just use some data that I make up. One of these is an example from the help on ListContourPlot3D and one is a 3D-Gaussian, list1 = Table[{x, y, z, x^2 + y^2 - z^2}, {x, -1, 1, .05}, {y, -1, 1, .05}, {z, -1, 1, .05}]~Flatten~2; list2 = Table[{x, y, z, 2 Exp[-3^2 ((x - .3)^2 + (y - .3)^2 + (z - .3)^2)]}, {x, -1, ...


8

If you have a relatively recent version of Mathematica, you don't need to use Evaluate. X = {Unique["x"]}; With[{x = X[[1]]}, Plot[Legended[2 x, x], {x, 0, 1}]]


7

If you leave ContourPlot outside you can get quite nice performance: static = ContourPlot[45 x^2 + 20 y^2 == 45, {x, -2, 2}, {y, -2, 2}, Frame -> False]; dynamic = ContourPlot[8 x^2 + 4 x y + 5 y^2 == 9, {x, -2, 2}, {y, -2, 2}, Frame -> False, ContourStyle -> Orange]; Manipulate[ Graphics[{ First@static, ...


7

I took this code out of the examples given in ListSliceContourPlot3D . I only added the option BaseStyle -> Opacity[.6]. data = Table[x + y + z, {z, -1, 1, 0.2}, {y, -1, 1, 0.2}, {x, -1, 1, 0.2}]; Table[ ListSliceContourPlot3D[data, sl, BaseStyle -> Opacity[.6], PlotLabel -> sl], {sl, {"XStackedPlanes", "YStackedPlanes", ...


7

Try this ContourPlot[Cos[x - y] + Sin[x^2 + 3 y], {x, -3, 3}, {y, -3, 3}, PlotTheme -> "Monochrome",ContourStyle -> Directive[White, Opacity@.1]] You can also use ColorFunction -> ColorData["GrayTones"] for gray shades or even write your own following the reference.


7

You ask whether it is "possible to define the areas with the same color as separate geometric regions in the sense of the computation geometry, and then work with these domains separately". This seems to me to be a great task for ImplicitRegion: regions = Table[ ImplicitRegion[i < x*Exp[-x^2 - y^2] <= i + 0.05, {{x, 0, 3}, {y, -3, 3}}], {i, 0, 0.4, ...


7

To answer the last question, the contour domains (since V8) are enclosed separately in GraphicsGroup, each which you can cull and turn into a region: plot = ContourPlot[x*Exp[-x^2 - y^2], {x, 0, 3}, {y, -3, 3}, PlotRange -> {0, 0.5}, ColorFunction -> "Rainbow"]; regs = With[{coords = First@Cases[plot, GraphicsComplex[p_, ___] :> p, Infinity]}, ...


7

Another option is to use DenistyPlot3D. You can set your own custom OpacityFunction and ColorFunction (by default they take scaled values between 0 and 1) DensityPlot3D[ 1/(1 + x^2 + y^2 + z^2), {x, -5, 5}, {y, -5, 5}, {z, -5, 5}, PlotPoints -> 100, OpacityFunction -> Function[f, (Exp[4 f] - 1)/(E^4 - 1)], ColorFunction -> ...


6

You could use SliceContourPlot3D: expr = TransformedField["Spherical" -> "Cartesian", (Cos[θ - π/2] Cos[ϕ])^(1/4), {r, θ, ϕ} -> {x, y, z}]; SliceContourPlot3D[expr, "CenterSphere", {x, -1, 1}, {y, -1, 1}, {z, -1, 1}] The missing parts of the sphere are where your expression isn't real.


6

Another way is to use the MATLink package (see Calling MATLAB from Mathematica), if you have Matlab installed. (* See http://matlink.org for installation *) Needs["MATLink`"]; OpenMATLAB[] test = MScript["test", " %******************************************** clear M=[ % Frequence Amplitude Phase 10 9.359000E+0 1.340000E+0; ...


6

If you do not want to axes to dynamically redraw themselves to stay in view as you rotate then you can use AxesEdge to fix their location. Graphics3D[{RGBColor[113/255, 190/255, 236/255], Cuboid[{0, 0, 0}]}, Axes -> True, AxesEdge -> {{-1, -1}, {-1, -1}, {-1, -1}}, PlotRange -> {{0, 2}, {0, 2}, {0, 2}}, Boxed -> False] But in this case ...


6

I think what is reported in this question is a bug that is affecting many of the Plot family of functions in V10.X for X >= ?. The problem occurs when a plot has to deal with numbers outside the range {$MinMachineNumber, $MaxMachineNumber} {2.22507*10^-308, 1.79769*10^308} Since the OP's problem only occurs near the singularity at zero, let's reduce ...



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