Tag Info

New answers tagged

2

It may depend on what you would like to achieve visually with your plot. I'll create some fake data to represent yours: distanceplot = Table[{x, 2 x}, {x, 0, 100, 1}]; Here are two ways to achieve what you asked, which lead to somewhat different results The first example, which I suggested in the comments, provides an explicit limit for the horizontal ...


1

You could let FindDivisions do the work: scale = (9.11/10^31) FrameTicks -> {{1, 2, 3}, ( # { scale , 1}) & /@ FindDivisions[{-2*10^-28 /scale, -2*10^-32 /scale}, 8], None, None} FrameTicks -> {{1, 2, 3}, {{-2.2775*10^-28, -250}, {-1.822*10^-28, -200}, {-1.3665*10^-28, -150}, {-9.11*10^-29, -100}, {-4.555*10^-29, -50}, {0., ...


4

Here is a function that does what you want, I think: trimPoint[n_, digits_] := (*display number n with given number of sig.digits, trim trailing decimal point*) NumberForm[n, digits, NumberFormat -> (DisplayForm@ RowBox[Join[{StringTrim[#1, RegularExpression["\\.$"]]}, If[#3 != "", {"\[Times]", SuperscriptBox[#2, #3]}, {}]]] &)] ...


2

$Version "10.2.0 for Mac OS X x86 (64-bit) (July 7, 2015)" dat = Transpose@{Range@40, RandomReal[{.8, 1.2}, 40]*Range@40}; Legended[ ListPlot[dat], Placed[ LineLegend[{Blue}, {Style["I want a line legend!!!", 14]}], {.3, .8}]]


3

A more efficient method to calculate the B-Spline curve is Cox-De Boor algorithm Implementation (* Do binary search *) biSearch[knots_, {low_, high_}, u0_] := With[{mid = Floor[(low + high)/2]}, If[u0 < knots[[mid]], {low, mid}, {mid, high}] ] (* Search the index of span [u_i,u_i+1]) *) searchSpan[{knots_, deg_}, u0_] := First@ NestWhile[ ...


11

This is not a bug. I think that this is not a bug, see addendum. Based on my (limited!) experience, I believe that LineLegend and PointLegend are in fact the very same thing with differing default options. LineLegend has Joined -> True while PointLegend has Joined -> False by default, but otherwise they are identical. The syntax you used, i.e. ...


6

This is complementary to bbgodfrey's answer: PlotRange is an option for Graphics, and PlotRange -> All means "show everything". All the options that can be given in Graphics can also be given in plotting functions such as ListPlot, Plot, etc. Usually, they have the same meaning as in Graphics, but there are exceptions. PlotRange is a fairly subtle ...


3

This was not acknowledged (yet) by Wolfram but appears to have been fixed on version 10.2.0.0


1

kB = 8.617*10^-5;(*ev/k*) Ea = 20*10^-3;(*ev*) e = 1.6*10^-19; h = 4.1*10^-15; G0 = 10*e^2/h; G1[x_] := G0*E^(Ea*x/kB); Plot[G1[x], {x, 0.004, 0.01}] Have fun!


1

This is taking your first modification of the original code and just changing the way f is defined, then using that function inside the module. It seems to work fine for me. Clear[x, y, f]; x = 10;(*Global values have no effect on Module...*) y = 12;(*Global values have no effect on Module...*) f[x_, y_] := E^(-x^2 - y^2) + x y; Manipulate[ Module[ {x, ...


5

The workaround is to put an \[InvisibleSpace] between the degree symbol and the C. Plot[x, {x, 0, 1}, FrameLabel -> {"x", "temperature / \[Degree]\[InvisibleSpace]C"}, Frame -> True] Note that the ImagePadding isn't very good in this case, but the C does indeed have the right baseline.


5

There appears to be a bug in RandomPoint, as can be seen by plotting both region1 and region2, the latter defined by region2 = ImplicitRegion[6 <= x - y + 2*z <= 7, {{x, -5*Pi, 5*Pi}, {y, -5*Pi, 5*Pi}, {z, -10, 10}}]; Then pts2 = RandomPoint[region2, 10^4]; ListPointPlot3D[{pts2, pts1}, AxesLabel -> {"x", "y", "z"}, BoxRatios -> {1, 1, ...


3

In the answer of Karsten 7. the BarLegend is shown as a Cell expression, and since I want to use the legend in an actual plot, it is not immediately useful. However, with the help of his/her answer, I managed to solve my problem. First I make the legend: barLegend = ToExpression[FrameBox@@MakeBoxes[ BarLegend[{"SunsetColors", {0, 1}}, LegendMarkerSize ...


10

When different plots use conflicting options, Show uses the first one listed. So, here it is using the PlotRange of the first graphics instance. Use Show[Table[ListPlot[{{i, i^2}}], {i, 1, 10}], PlotRange -> All] instead to see all the points. Further Explanation To see more clearly what is happening, consider the InputForm (as suggested by ...


0

This might be the problem: The date axis is automatic. Note the time for the datapoint value 6 is 9pm. The axis automatically shows a tick label at 10pm. data = { {{2015, 7, 28, 18, 0, 0}, 3}, {{2015, 7, 28, 21, 0, 0}, 6}, {{2015, 7, 29, 4, 0, 0}, 1}, {{2015, 7, 29, 6, 0, 0}, 2}}; DateListPlot[data, DateTicksFormat -> {"DayNameShort", " ...


7

This is the result of Plot Themes. This restores the old behavior: SetOptions[ParametricPlot3D, PlotTheme -> None]; More specifically the default Theme results in embedded Lighting values: Cases[ ParametricPlot3D[{f[t, z] Cos[t], f[t, z] Sin[t], -z}, {t, -Pi, Pi}, {z, 0.35 Pi, Pi}, Mesh -> None, PlotStyle -> Specularity[0], PlotTheme -> ...


2

I went back to the old legend functions that I used before BarLegend existed, and tried the following: First, copy the definitions of trimPoint, colorLegend, display and at by selecting the large code block in the section Color bar legend. Then do this: display[{ colorLegend[ ColorData["SunsetColors"], {-.5, .5}, LabelStyle -> ...


4

Both Module and DynamicModule are shadowing the global variables x and y in the example in which you use them. The demonstration is best written without using either Module or DynamicModule. Manipulate[ ContourPlot[f, {x, -1, 1}, {y, -1, 1}, Contours -> 20, Epilog -> Dynamic[Arrow[{pt, pt + grad /. {x -> pt[[1]], y -> pt[[2]]}}]]], {f, ...


9

Somehow the AbsolutThickness you specified gets replaced by a default value of AbsoluteThickness[0.2]. This misbehavior can be corrected by replacing the incorrect value with your specification. Needs["GeneralUtilities`"] PlotLegends; (*preload definitions*) Cell[BoxData[ MakePasteBox@ BarLegend[{"SunsetColors", {0, 1}}, LabelStyle -> ...


8

It appears to be a bug in computing the vertex normals at the step. Here's are the vertex normals: c = cylinderPlot3D[f, 0.6]; normals = FirstCase[c, GraphicsComplex[pts_, __, VertexNormals -> vn_, ___] :> Line[Transpose@{pts, pts + vn}], -1]; Show[c, Graphics3D[{Opacity[0.1], normals}]] It looks like the HeavisideTheta function is not being ...


6

Here is how you can get exact control over the exported page size directly from Mathematica: I'll assume I want exactly a 5 inch square page. Then I would create a GraphicsGrid instead of Grid from the plots, and output them in an Inset with a Graphics wrapper that has exactly 5 inches as its ImageSize: img1 = ListLinePlot[#, ImageSize -> 500] & ...


1

I think this is what you're asking: Show[ ContourPlot[ Sin[x + y], {x, 0, 2 \[Pi]}, {y, 0, 2 \[Pi]} , RegionFunction -> (#1 + #2 < \[Pi] &) ] , ContourPlot[ Sin[x + y], {x, 0, 2 \[Pi]}, {y, 0, 2 \[Pi]} , RegionFunction -> (#1 + #2 >= \[Pi] &) , ColorFunction -> GrayLevel ] ] Where I've used RegionFunction to give ...


4

One non-perfect workaround is to Magnify your graphics in order to fit the page width: Export["test1.eps", Magnify[Grid[{img1}], .8]] But perfect result can be achieved by Exporting to PDF and then converting PDF to EPS using a third-party tool like free pdftops utility which is a part of Poppler (you can download Windows binaries here): ...


8

so you understand whats happening, the image is all there and being cut off by whatever software you use to render because it is wider than the page. It may actually be ok if you use some other software that properly handles eps. Acrobat cuts it off which is really annoying since they literally wrote the standard, but just for example, it imports correctly ...


1

For me, Plot[y/.Solve[(x-2)^2+(y-2)^2]==1,{x,0,3}, AspectRatio->Automatic, AxesOrigin->{0,0}] did not have noticeable separation so I cannot help with that. I also successfully used ContourPlot if that works better for you. ContourPlot[(x - 2)^2 + (y - 2)^2, {x, -2, 4}, {y, -2, 4}, Contours -> {1}] If you just need circles, consider looking into ...


10

What you're seeing is the result of a discontinuous function (HeavisideTheta). The mesh algorithms assume things are continuous and do not always work well when they're not. It might be worth breaking up the plot according to the discontinuity, and inserting a sheet connecting the two pieces of the plot. f[t_, z_] := Cos[z/2]^0.5*(1 + HeavisideTheta[z - ...


10

Sharp border: f = {z, Cos[z/2]^(1/2) Cos[t]/0.6, Cos[z/2]^(1/2) Sin[t]*0.6}; ParametricPlot3D[f, {t, -Pi, Pi}, {z, -Pi, Pi}, MeshFunctions -> {Function[{x, y, u, t, z}, Evaluate@Dot[Cross @@ Transpose@D[f, {{t, z}}], {-2, 1, 0}]]}, Mesh -> {{0}}, PlotStyle -> Specularity[0], MeshShading -> {Black, LightGray}, PlotPoints -> 50, ...


4

Use larger value for PlotPoints. What is acceptable is subjective. You will need to experiment to find the smallest value with results that are acceptable to you for whatever your purpose is. ParametricPlot3D[{z, Cos[z/2]^0.5 Cos[t]/0.6, Cos[z/2]^0.5 Sin[t]*0.6}, {t, -Pi, Pi}, {z, -Pi, Pi}, Mesh -> None, PlotPoints -> 250, PlotRange -> All, ...


3

f[t_, z_] = Cos[z/2]^(1/2)*(1 + HeavisideTheta[z - 35/100 Pi]); Increase the number of PlotPoints ParametricPlot3D[ {f[t, z] Cos[t], f[t, z] Sin[t], -z}, {t, -Pi, Pi}, {z, -Pi, Pi}, PlotRange -> All, Exclusions -> None, PlotPoints -> 101]


1

As MarcoB says in his comment, add the option Exclusions -> None. f[t_, z_] := Cos[z/2]^0.5*(1 + HeavisideTheta[z - 0.35 Pi]); ParametricPlot3D[{f[t, z] Cos[t], f[t, z] Sin[t], -z}, {t, -Pi, Pi}, {z, -Pi, Pi}, PlotRange -> All, Exclusions -> None] plot


4

Here is a quick modification that uses numerical integration: since you are interested in plotting the function, numerical results should be just as acceptable: Clear[F] F[x_?NumericQ] := 2 x^2 ((Log[x])^2 - 3 Log[x] + 7/2) + 2 (1 - x)^2 ((Log[1 - x])^2 - 3 Log[1 - x] + 7/2) + 2 NIntegrate[(Log[t^2 + s^2])^2, {t, 0, x}, {s, 0, 1 - x}] + 1/2 ...


4

"Expressions" for legend in ListPlot family is used because of Association. With Association input, the plot will automatically pick up the keys as legends. Here is an example: ListPlot[<|"A"->{1,2,3},"B"->{2,3,4}|>] SetOptions is to set the default values to options but it doesn't guarantee that the settings will be used by the plot since ...


0

This question has been answered elsewere. As @kglr helpfully pointed out in the comments, the undocumented option: Method -> {"GridLinesInFront" -> True} will cause the gridlines to display over the fill and styled curves: LogLogPlot[{10^1 x^(-4/5), 10^15 x^(-4/5), 10^30 x^(-4/5)}, {x, 1, 10^40}, PlotRange -> {{0, 10^20}, Automatic}, ...


2

Supply the option PlotRange -> All: ParametricPlot3D[{Cos[z/2]^6*Cos[t], Cos[z/2]^6*Sin[t], z}, {t, -Pi, Pi}, {z, -Pi, Pi}, PlotRange -> All ]


1

With an typo corrected, the expression for q is q[v_, s_] := Sum[((-1)^p) (BesselJ[p, v]*BesselJ[2*s - p, v] + BesselJ[p + 1, v]*BesselJ[2*s + 1 - p, v]), {p, 0, 2 s}] It is instructive to plot it for various s Plot[Evaluate[Table[q[v, s], {s, 0, 10}]], {v, 0, 10}, PlotRange -> All, AxesLabel -> {v, "q"}] Evidently, q decreases ...


2

As Simon has already remarked, your Mathematica expressions do not reflect your LaTeX; assuming that the LaTeX is correct, then you can should be able to use the following: u[x_?NumericQ, y_?NumericQ, t_?NumericQ] := Module[ {r}, r = FindRoot[ Log[Abs[r]] + 1/2 Log[Abs[r^2 - 9/2 r + 9]] + 3 Sqrt[7]/7*ArcTan[(4 r - 9)/(3 Sqrt[7])] == 2 t, ...


2

You can get the set, these are ordered pairs, as you describe $(y,|x_2-x_1|)$ with the code: Table[{y, Abs[Differences[ x /. NSolve[Rationalize[Sin[x] == y] && -Pi <= x <= Pi, x, WorkingPrecision -> 20]]][[1]]}, {y, -.99, .99, .01}] The only problem is that over this interval, there is only one solution at $y=\pm 1$. You see I have ...


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 && ...


2

u[x_?NumericQ, y_?NumericQ, t_?NumericQ] := Sign[x + y - t + rr[t]] (Exp[x + y - t + rr[t]] - 1) + rr[t]*Exp[x + y - t + Log[1/9*rr[t]^2 - 1/2*rr[t] + 1]] rr[t_] := r /. FindRoot[ 2 t - Log[Abs[r]] + (1/2) Log[Abs[r^2 - 9/2 r + 9]] + 3 Sqrt[7]/7*ArcTan[(4 r - 9)/(3 Sqrt[7])], {r, 1}] This can plot ...


3

I think the function you are looking for is RevolutionPlot3D. I chose to plot rho from 0 to 5 and tau from 0 to 2 pi. f[rho_, tau_] := 3139.30526902869 + 102.123379245362 rho^2 - 15.5488797234294 rho^3 - 266.860422394968 rho^4 + 352.939022246368 rho^5 - 177.650227764971 rho^6 + 32.3137965311735 rho^7 + 0.5 ((71.3031143385107 rho + ...


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]; ...


2

I am not sure I understand the question, but that has never stopped me before, so here goes: L = 300; Subscript[β, 0] = 0.0005; Subscript[ψ, 0] = 0.001; The following definitions contain modifications to the OP's code. th1 = Table[ {Subscript[β, 1], (Subscript[β, 0]*(Subscript[ψ, 0]*L) - Subscript[β, 1])/(Subscript[β, 1]*L)}, ...


4

Note that Piecewise functions are a special case in Integrate if the integral is in the form of an indefinite integral. (One can add a constant as needed to adjust for a different starting point, but in the OP's example, it is unnecessary.) This evaluates relatively quickly: foo = Piecewise[{(t - #[[1]])^2, #[[1]] <= t && t < #[[2]]} & /@ ...


3

First thing I would note is that you should Integrate the function analytically before plotting it. To do so you should add your assumptions like already commented by other users (note that it is important to use set (=) instead of set delayed(:=) to do the integration only once): f[t_] = Piecewise[{(t - #[[1]])^2, #[[1]] <= t && t < #[[2]]} ...


1

Essentially the same as Simon Woods's comment: SeedRandom[1] data = Partition[Sort[Join[{0}, RandomReal[{0, 10}, 20], {10}]], 2, 1]; You don't need the And with the inequality f[t_] = Piecewise[{(t - #[[1]])^2, #[[1]] <= t < #[[2]]} & /@ data]; You need to add an assumption to the Integrate for it to evaluate Plot[Evaluate@Assuming[x >= ...


8

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 ...


4

As the following demonstration shows, NumberLinePlot gives up at four intervals. On this showing I would call it a bug. Manipulate[ Show[ Plot[Sin[n x N[Pi]], {x, 0, 1}], NumberLinePlot[0 <= Sin[n x N[Pi]], {x, 0, 1}, Spacings -> 0, PlotStyle -> Red], ImageSize -> Large], {{n, 2}, 2, 12 , 1, Appearance -> "Labeled"}]


4

David, replace Method -> {Refinement -> {ControlValue -> (90 - n °)}} with Method -> {Refinement -> {ControlValue -> (90 - n) °}}`


3

The problem appears to be with specifying Automatic for the colors with PointLegend rather than letting it default. $Version "10.2.0 for Mac OS X x86 (64-bit) (July 7, 2015)" pValues = {0.3, 0.5, 0.8}; dat = Table[{k, PDF[BinomialDistribution[50, p], k]}, {p, pValues}, {k, 0, 50}]; ListPlot[dat, Filling -> Axis, PlotLegends -> ...


4

I propose using the lower-level System`PlotThemeDump`resolvePlotTheme to find the information you need. This reveals the color scheme number itself rather than resolving to a list of Directives. You must give the plot function name as a String. The key you are looking for is "DefaultColor: Themes`ThemeRules; (* preload PlotThemes subsystem *) ...



Top 50 recent answers are included