Tag Info

Hot answers tagged

13

Wanna listen to a story? :) It was around 2002 when I finally became fed up with ParametricPlot3D[] and its inability to adaptively plot space curves. Recall that this was the old Graphics[] system where all the pictures were effectively done in PostScript. Thus, I set out to look for a way to adaptively plot curves in general. I was at the time very ...


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


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


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


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

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


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


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


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


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


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


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


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


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


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


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


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]}, {}]]] &)] ...


4

This isn't pretty, but it works: BarChart[{ {Labeled[1,"c1"],Labeled[3,"c2"],Labeled[4,"c3"]},{Labeled[4,"c4"], Labeled[5,"c5"]}}, ChartLabels -> {{"r1","r2"},None} ]


3

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


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


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]


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


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


3

You can define a function to label the data using Labeled as in @David's answer: lblngF = MapIndexed[Function[{d, p},Labeled[d, #2[[1]][[## & @@ p]]]], #, {#2[[2]]}] &; lblF = Fold[lblngF, #, Thread[{Reverse@#2, {2, 1}}]] &; dt = {{1, 3, 4}, {4, 5}}; labels = {{"r1", "r2"}, {{"c1", "c2", "c3"}, {"c4", "c5"}}}; BarChart[lblF[dt, labels]] ...


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


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



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