Tag Info

Hot answers tagged

19

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


12

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


12

Let us look at the structure of the produced Graphics expression using the shortInputForm function: Plot[{Sin[t], Cos[t]}, {t, 0, 2 Pi}, Mesh -> {10, 20}, MeshStyle -> Directive[PointSize[Large]]] // shortInputForm We see that all the Mesh points present as single Point primitive. It means that even on the level of internal structure of the ...


12

data = Import["orbit3d.out", "Table"]; (* Your Table is not needed; you can use [[...]] instead *) (*d=Table[{data[[i,2]],data[[i,3]],data[[i,4]]},{i,1,Length[data]}];*) d = data[[All, 2 ;; 4]]; l = Line[d]; (* Projections on bounding box *) lz = l /. {x_, y_, z_} -> {x, y, -5.5}; ly = l /. {x_, y_, z_} -> {x, 5.5, z}; lx = l /. {x_, y_, z_} -> ...


11

I would simply do Dot[Conjugate[#1], #2] & @@@ Partition[mm, 2, 1] and do away with the sequential numbers, as those are easy enough to generate when needed any way (MapIndexed?) ListPlot does not need these indices. But instead of jumping straight to the solution, let's take your code and improve it step by step. Instead of arr[[i]][[j]] you can ...


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


10

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


10

I have reworked your code somewhat. I hope what I have done will help you with your problem. BezierDefinition[pts_, u0_?NumericQ] := Nest[MovingAverage[ArrayPad[#, 1], {u0, 1 - u0}] &, {1}, Length[pts] - 1].pts ClearAll @ CAGDBezierCurve; Options[CAGDBezierCurve] = {SplineClosed -> False, SplineDegree -> Automatic, ControlPoints -> ...


10

If you are serious about using this extensively, consider making a function based on CreateDocument... Here is one way to pursue Szabolcs's line of thought. We will write a function based on CreateDocument and use it in conjunction with the (now somewhat neglected) option DisplayFunction, which handles where the output of graphics functions should be ...


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


9

The main issue is simply that your constraint should not be imposed after the integration of the field lines, but beforehand. This means that we should choose the starting points from which the differential equations of the field lines are integrated to lie on the desired cylinder right from the beginning. Then, all you have to do is to impose the ...


9

p[x_, left_, right_] := If[left < x < right, 1, Undefined] Plot[{Emin p[wk, 0, 4], Emax1 p[wk, 0, 2], Emax2 p[wk, 2, 4]}, {wk, 0, 4}, Filling -> {1 -> {{2}, Pink}, 1 -> {{3}, Pink}}] Edit You may also use for example the more idiomatic p[x_, left_, right_] := 1 /; left < x < right for the same purpose. What you need is ...


9

Not so fancy as transforming an image, but I like how the mesh in ParametricPlot shows the deformation. {chvar} = Simplify[ Solve[u == x y && v == y - x && y > 0 && x > 0, {x, y}, Reals], 1 <= u <= 4 && 0 <= v <= 2] (* {{x -> (2 u)/(v + Sqrt[4 u + v^2]), y -> 1/2 (v + Sqrt[4 u + v^2])}} *) ...


9

You can always create a new notebook and put things in it. If you are serious about using this extensively, consider making a function based on CreateDocument that sets the appropriate options for the notebook to look good. Check what CreateDocument@Plot[Sin[x],{x,0,10}] does. Or use a quick-and-dirty hack based on CreatePalette: fig = CreatePalette[#, ...


8

I will post this to avoid confusion - region has a new meaning in WL since Geometric Computation was introduced in V10. Relative to that meaning what you showed is not a WL region because you cannot compute over it, but of course is a visual of some mathematical region defined analytically and shown with help of Filling. To achieve the same via computable ...


7

I'm sorry for a delay. The cause of this problem originates from my thoughtless approach and/or abuse of specific case of a Sinusoidal projection. I was using n Degree to specify ticks position. It was working so I wrongly assumed it gets positions in projection automatically. As we can see, it's not the case. Answer: we have to project ticks positions ...


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


7

I'm not sure how many levels you are talking about but if reasonably small you can scan through the different levels using Manipulate and use the level to set the opacity value. Manipulate[ DynamicModule[ { opacity = ConstantArray[Opacity[0.2], 3] }, opacity[[level]] = Opacity[1.0]; ListPlot3D[{level1, level2, level3}, PlotStyle -> ...


7

Since there is really something wrong with the BezierCurve, I made this work-around: Clear[bezierCurve]; bezierCurve[pts_] := First@ParametricPlot[ BezierFunction[pts, SplineDegree -> Length[pts] - 1][t], {t, 0, 1}] Manipulate[ Graphics[{bezierCurve[pts], Dashed, Green, Line[pts]}, PlotRange -> {{-.5, 1.5}, {-.5, 1.5}}, Frame -> ...


7

Adam, I think this is probably what you mean: {a, b} = {6, 7}; t = 0; dt = 0.001; loopvals = Part[#, 2, 1] &@ Reap@ Do[ {l, m} = With[{r = NSolve[{x - y == a, 2 x + y == b}, {x, y}]}, Extract[r, Position[r, _?NumericQ]]]; t = t + dt; a = a + (l + m) a dt; b = b + l m b dt; Sow[{a, b}], {1000} ]; ...


7

I am glad that you are using Mathematica in your high school project. I think you forgot to mention in your question that the code you posted doesn't actually produce the image you showed; you may also want to mention where you obtained that image. Anyway, since your figure is made up of repeating units, I generated one unit, then translated it multiple ...


7

Here is a rework of your code that I think produces what you are asking for. One issue I have not addressed is plot filling because I think it a bad idea with so many functions on the plot. I also made some minor changes to the control layout to get a more compact display. You can easily restore your original layout if you like. Manipulate[ Column[ ...


7

To get the region, you can use region plot, you should take the limits of the integral exactly as they are written and supply them to the function, separating the region corresponding to each integral by the And function(&&). The edge is a little jagged, but you can play with the number of plot points to get a better or worse picture. RegionPlot3D[ ...


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


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

Let's assume you really can only evaluate your function evals for numeric values. Then the approach of using Evaluate or removing ?NumericQ is not helping. For this situation, I see two possible solutions from the top of my head. Using memoization suppress recalculation evals[x_?NumericQ] := evals[x] = Eigenvalues[{{x^2, 2 x}, {x, 3 x^2}}]; ...


6

A = {{1, 2}, {3, 4}}; BarChart3D[A, ChartLayout -> "Grid", Boxed -> True, Method -> {"Canvas" -> None}]


6

Also Most@MapThread[Dot, {Conjugate@mm , RotateLeft@mm}] Or Dot @@@ Transpose@{Conjugate@mm , RotateLeft@mm} // Most Or something like shooting yourself in the foot :D ListCorrelate[{Conjugate, Identity}, mm, 1, 0, #1[#2] &, Dot, 1] // Most


6

In version 10.2 there is a new suite of functions that may be helpful: f[x_, y_, z_] := Sin[x/4]*Sin[y/4]*Sin[z/4]; xyzw = Flatten[Table[{x, y, z, f[x, y, z]}, {x, 1, 10}, {y, 1, 10}, {z, 1, 10}] // N, 2]; ListSliceContourPlot3D[xyzw, "CenterPlanes"]


6

You can divide all of your data by 1/10th of the smallest absolute value before doing the log transform. This essentially scales the data to all have logs greater than one without adding a discontinuity on your axis. Then you can show the sign*log of positive and negative values from your original data on the same axis. d = {-3.7*^-7, -1.81*^8, 1.5*^6, ...



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