Tag Info

New answers tagged

3

If you want a curve whose shape is determined by y = 1/2 (ArcCos[1 - Cos[2 x]]) and whose color is determined by Sin[x] Sin[y], you may use Plot[1/2 (ArcCos[1 - Cos[2 x]]), {x, -\[Pi]/4, \[Pi]/4}, ColorFunction -> Function[{x, y}, ColorData["SunsetColors"][Sin[x] Sin[y]]]]


1

Starting from this Plot3D: Plot3D[ Exp[-x^2 - y^2], {x, -3, 3}, {y, -3, 3}, PlotPoints -> 100, PlotRange -> {0, 1}, PlotRangePadding -> None, Mesh -> None, PlotPoints -> 50, BoxRatios -> {1, 1, 1}, Boxed -> False, AxesLabel -> Automatic, ViewPoint -> {-2, -2, 3} ] let me address the question of how to use ...


3

No need folding 1D graph to get a 2D Random walk in Mathematica. and the CCW easy in Mathematica. Here we go: Generate data set for the random sequence with 2000 steps. Alternatively, you may use your "own generated" data set. rdata = Accumulate[RandomChoice[{-1, 1}, {2000, 2}]] Now plot it with similar layout as your example ListLinePlot[rdata, ...


4

rw = Accumulate@RandomChoice[{-1, 1}, 400]; ListLinePlot[rw, AspectRatio -> 1] rw2 = Transpose[{rw[[ ;; 200]], rw[[201 ;; ]]}]; llp2 = ListLinePlot[rw2, AspectRatio -> 1] To rotate llp2: Show[MapAt[GeometricTransformation[#, RotationTransform[-45 Degree]] &, llp2, {1}], PlotRange -> All] Aside: Using InterpolationOrder->0 ...


4

ListLinePlot[Accumulate @ Prepend[RandomChoice[{{-1, 0}, {1, 0}, {0, -1}, {0, 1}}, 1000], {1, 1}], AspectRatio -> Automatic] Starting with some random data rd = RandomChoice[{1, -1}, 2000]; ListLinePlot[Accumulate@rd] Creating a random walk similar to the one shown in your question rw = Accumulate@Transpose[{rd[[;; 1000]], rd[[1001 ...


2

You can use ConditionalExpression using all the conditions that define the region you want to plot as the second argument: ClearAll[x, m, m3, s1min, s1max] x[s1_, s2_] := Sin[s1 + s2]; m = Sqrt[Pi/32]; m3 = Sqrt[Pi/64]; s1min[s_] := Sqrt@s; s1max[s_] := 2 + Sqrt@s; Plot3D[ConditionalExpression[x[s1, s2], (m3^2 + m^2)^2 <= s2 <= (Sqrt[s1] - m^2)^2 ...


3

First question answered, here we go with LegendMarkerSize: legend = LineLegend[styles, {"f", "g"}, LegendMarkerSize -> 5]; Second question answered: Customize a Grid for the legend using the Spacing option and use it in LegendLayout. Play around with Spacing values for horizontal and vertical adjustments. Here we go table[pairs_] := Grid[pairs, ...


0

Cases[Plot[Sin[x], {x, 0, 10}], _[PlotRange, x_] :> x, -1][[1]] (*{{0, 10}, {-0.999999, 1.}})*


3

You can add Specularity to the ColorFunction. Here is a Manipulate you can play with to figure out what settings you prefer: Manipulate[ Plot3D[Exp[-x^2 - y^2], {x, -3, 3}, {y, -3, 3}, PlotPoints -> 50, PlotRange -> All, PlotRangePadding -> None, ColorFunction -> (Directive[Specularity[s, 20], Glow@ColorData["DarkRainbow"][#3]] ...


7

Also PlotRange[plot] PlotRange /. AbsoluteOptions[plot] Last @@ AbsoluteOptions[plot, PlotRange] PlotRange /. plot[[2]] all give (* {{0.,10.},{-0.999999,1.}} *) Note: Regarding usage of PlotRange as a function, it is undocumented, and the earliest reference I could find on this site is this answer dated Oct 11, 2012: The same range on each plot in a ...


2

Anyway, while I wait for my flight, here's some code that'll give you everything there is to know about a plot. GetGeometry[g_Graphics] := Module[{ q, dim, plotrange=PlotRange/.AbsoluteOptions[g,PlotRange], }, q=Rasterize[Show[g, ...


3

FilterRules[AbsoluteOptions[plot], PlotRange] does the trick (*{PlotRange -> {{0., 10.}, {-0.999999, 1.}}} *) Not sure if this is an exhaustive answer.


5

While @Szabolcs has provided the correct work-around, the actual issue has to do with automatic use of Compile for function evaluation. The affected range is such that the value of Gamma[1+n] is still a machine real, but their product is out-of-bound. The issue comes, because the default setting of Compile's RuntimeOptions is to tolerate machine arithmetic ...


5

Gamma is an extremely quickly increasing function, so you're dealing with the ratio of huge numbers here. Something similar to catastrophic cancellation can happen. Fortunately, Mathematica is very good at dealing with this situation if you let it use arbitrary precision instead of machine precision. Change 0.5 to 1/2 and add something like ...


0

Here is a way to do what you are asking. Before Plot[Sin[200 Pi t], {t, 0., .01}] After Plot[Sin[200 Pi t], {t, 0., .01}, Ticks -> {{#, 1000 #} & /@ FindDivisions[{0., .01}, 5] // N, Automatic}]


0

Plot[x^2, {x, .0001, .0005}, Ticks -> {Table[{i, ToString[10000 i]}, {i, .0001, .0005, .0001}], Automatic} ]


4

You have a typo in the syntax: Plot[{Sin[x], Cos[x]}, {x, 0, 2 Pi}, PlotLegends -> {"sine", "cosine"}] You forgot 's' in PlotLegends.


0

There was also a very complete answer to my question given in a near duplicate as pointed out by Lou in the comment above, see: How can I make an X-Y scatter plot with histograms next to the X-Y axes?. In my example, a simple change from GraphicsGrid to Grid fixed the issue with the marginal plots standing off so far. Module[ {jointPDF, marg1PDF, ...


3

Epilog may be useful to you: Module[{jointPDF, marg1PDF, marg2PDF, mu1, mu2, s1, s2, rho, size, jointPlot, marg1Plot, marg2Plot, x1, x2}, mu1 = mu2 = 0; s1 = s2 = 1; rho = 0.4; jointPDF = PDF[MultinormalDistribution[{mu1, mu2}, {{s1, rho}, {rho, s2}}], {x1, x2}]; marg1PDF = PDF[NormalDistribution[mu1, s1], x1]; marg2PDF = ...


2

Using BarChart3D If you have to use BarChart3D you need to pre-process the input data to a form acceptable to BarChart3D, i.e., a list of lists of bar heights. Since your x and y values are integers you can get an array of bar heights using SparseArray: barchrtdata = SparseArray[{#, #2} -> #3 & @@@ test, Automatic, Indeterminate]; ...


2

As I understood your task, you need to switch you center of coordinates to point associated with center of mass and plot the radius-vectors in this coordinate system: r1n = {r1x[#] - rCx[#], r1y[#] - rCy[#], r1z[#] - rCz[#]} &; r2n = {r2x[#] - rCx[#], r2y[#] - rCy[#], r2z[#] - rCz[#]} &; ParametricPlot3D[{r1n[t], r2n[t]}, {t, 0, 34}, PlotStyle ...


2

There are several ways, I give it a try. One is to use ListPlot3D with option InterpolationOrder -> 0 and Filling -> Bottom. Here a slightly modified example from the documentation: square[{{imin_, imax_}, {jmin_, jmax_}}] := Table[UnitStep[i - imin, imax - i] UnitStep[j - jmin, jmax - j], {i, 0, 20}, {j, 0, 20}] and ListPlot3D[ ...


2

Use FrameLabel instead. AxesLabel requires the origin to be present (and Axes -> True if you move the origin with AxesOrigin, unless AxesLabel -> Automatic).


6

A computer is a finite machine and there is a limit to how well you can visually explore such functions. Perhaps it will give enough of a impression to sum only a few terms. Even 5 terms exceeds the monitor's ability to display all the turns. Plot[ Evaluate@Table[Sum[(1/2)^n*Cos[3^n*Pi*x], {n, 0, k}], {k, {1, 2, 5}}], {x, 0, 3}, PlotStyle -> ...


7

If I understand the question correctly, PolarPlot[Cos[2 t] Sin[2 t], {t, 0, 2 Pi}, PlotStyle -> Directive[Red, Dashed], PolarAxesOrigin -> {Pi/2, .5}, PolarGridLines -> Automatic, PolarAxes -> True, PolarTicks -> {Table[{N[Pi/6 i], ToString[30 i] <> "°"}, {i, 0, 11}], Table[{0.1 i, 0.1 i}, {i, 4}]}] produces the desired ...


0

Working further from the answer I gave here, you can do it with ParametricPlot[{range[t], height[t]}, {t, 0., 5.24}, AspectRatio -> 1/2] One advantage of working with interpolating functions is that they behave like built-in functions when it comes to plotting. Update if you don't want use that method, but want to go down your own path, that's ...


0

Your functions x and y appear to be only defined on integers, so you can only plot them over the integers. One way is to use ListPlot. h = .01; g = 9.8; x[0] = 0; y[0] = 0; V[0] = 40; Vy[0] = 40 Sin[40 \[Degree]]; Vy[n_] := Vy[n - 1] - g*h; Vx[n_] := 40 Cos[40 \[Degree]]; x[n_] := x[n - 1] + 40 Cos[40 \[Degree]]*h; y[n_] := y[n - 1] + Vy[n - 1]*h; ...


4

You can use the option PlotStyle to style each of the three parts separately: PlotStyle -> {Opacity[.6], EdgeForm[{Opacity[1], Thick, Blue}], EdgeForm[{Opacity[1], Thick, Red}]} Since the three-argument form of ParametricPlot3D produces polygons (i.e., those lines are not Lines!), you need to set the styles using EdgeForm. We get a much cleaner ...


0

As I understood, you mean something like this: list = Flatten[Table[{i - 15, j - 15, 5 Exp[-(((i - 15)^2 + (j - 15)^2)/16)]}, {i, 0, 30}, {j, 0, 30}], 1]; ListPlot3D[list, PlotRange -> All, InterpolationOrder -> 3, MaxPlotPoints -> 25, ColorFunction -> Function[{x, y, z}, ColorData["Rainbow"][z]]] I choose the "Rainbow" colorset but ...


1

Update 2: And ... don't forget BubbleChart3D: Modify {x,y,z} triples to {x, y, z, 1} and Style each each based on the second column values in data: data2 = Style[Join[#, {1}], ColorData[{"Rainbow", {min, max}}][#2]] & @@@ data; and use with BubbleChart3D: BubbleChart3D[data2, BubbleSizes -> {.01, .01}, ViewPoint -> {1.5, -1.5, 2.5}, ...


8

adjmat = {{0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, {1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0}, {0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, ...


3

Here is a very simple version of what you seem to be looking for. First I enter some fake data: points = {{0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 1}, {0, 0, 1}, {0, 1, 0}}; am = {{0, 1, 0, 0, 1, 0}, {1, 0, 0, 0, 1, 0}, {0, 0, 0, 1, 0, 1}, {0, 0, 1, 0, 0, 1}, {1, 1, 0, 0, 0, 0}, {0, 0, 1, 1, 0, 0}}; i.e. points (their coordinates) and adjacency ...


1

Not sure how you want to place the displaypoints relative to the boxes, but ... you can find the coordinates of the bounding boxes using the ChartElementFunction as follows: Manipulate[Module[{boundingboxes = {}}, Row[{BoxWhiskerChart[data, ChartStyle -> {Red, Purple}, ImageSize -> 400, BarOrigin -> barorigin, BarSpacing -> {within, ...


2

funcs = {Sin[x], Cos[x], Sin[x] Cos[x]}; tips = {"t1", "t2", "t3"}; Plot[Thread[Tooltip[funcs, tips]], {x, -2 Pi, 2 Pi}, Evaluated -> True] Plot[Evaluate@Thread[Tooltip[funcs, tips]], {x, -2 Pi, 2 Pi}] Plot[Evaluate@MapThread[Tooltip, {funcs, tips}], {x, -2 Pi, 2 Pi}] Plot[Tooltip @@@ Transpose[{funcs, tips}], {x, -2 Pi, 2 Pi}, Evaluated -> True] ...


0

Update: To get a dashed line from the point {x,y} down to the x axis, use Epilog -> {{Dashed, Line[{{x, 0}, {x, y}}], Line[{{20, y}, {x, y}}]}, {AbsolutePointSize[32], Inset[car, {x, y}]}}] You can change your epilog to: Epilog -> {{Dashed, Line[{{x, 42}, {x, 20}}], Line[{{20, y}, {x, y}}]}, {AbsolutePointSize[32], Inset[car, ...


1

Maybe something like this: ListDensityPlot[ Table[Y^2 + Z^2, {Y, -1, 1, Pi/300}, {Z, -1, 1, Pi/300}], ColorFunction -> "SunsetColors", RegionFunction -> Function[{x, y, z}, TrueQ[0 <= y + 1/2 (ArcCos[1 - Cos[2 x]]) <= 0.785 - .74] \[Or] TrueQ[.74 - 0.785 <= y - 1/2 (ArcCos[1 - Cos[2 x]]) <= 0]], PlotLegends -> ...


1

You would probably need to ask Mathematica to treat your numbers as arbitrary-precision numbers by tagging the number of digits you'd like Mathematica to keep track of at the end of your numbers like this: 9.61677463456185765`20 This produces a plot: Plot[ f[Sqrt[9.8], 24, x] 10^8, {x, 9.61677463456185765`20, 9.61677463456185768`20} ] In drawing ...


1

It really is not different from what I suggested in comments. I now Map(/@) Style to every part of the title, but you could have done it manually in each string: PlotLabel -> Row[Style[#, 16] & /@ {"Was I Speedy? if your speedometer reads ", NumberForm[r, {4, 0}], " mph, you're actually traveling to: ", NumberForm[r*y/x, {4, 0}], "mph"}] ...


1

It seems to me you have found a bug. The following is a work-around you might use to get the labeling you want. The trick depends on the y-axis labels you want being related to the labels you are getting by a simple linear function. yTicks = {#, 8000 - #} & /@ (1000 Range[2, 5]) {{2000, 6000}, {3000, 5000}, {4000, 4000}, {5000, 3000}} sound = ...


0

Not sure if this will work, but I had a styling issue that was helped with: Awful styling in MMA10's Plot


5

Using BoundaryStyle Use the option BoundaryStyle and set the option value to {{1, 2} -> Directive[Thick, Red]}: Plot3D[{-5 - x - y, -Sqrt[8 x^2 + 8 y^2]}, {x, -5, 5}, {y, -5, 5}, Mesh -> None, BoxRatios -> {1, 1, 1}, BoundaryStyle -> {{1, 2} -> Directive[Thick, Red]} ] Using MeshFunctions Use the difference between the two functions ...


3

Find equations for intersection: Solve[-5 - x - y == -Sqrt[8 x^2 + 8 y^2], x] {{x -> 1/7 (5 + y - 2 Sqrt[2] Sqrt[25 + 10 y - 6 y^2])}, {x -> 1/7 (5 + y + 2 Sqrt[2] Sqrt[25 + 10 y - 6 y^2])}} Range of y: Solve[25 + 10 y - 6 y^2 == 0, y] {{y -> 5/6 (1 - Sqrt[7])}, {y -> 5/6 (1 + Sqrt[7])}} Draw intersection: inter = With[ { x1 = ...


1

This may be a workaround : Export["test.pdf", Plot[0, {x, 0, 1}, Frame -> True, FrameLabel -> {"c", ToString[\!\(\*FractionBox[\(a\), \(b\)]\)]}]] Simply wrap ToString around and you will get the correct output.


1

I think I'd use MapThread here, instead of either Table or Map plus Transpose. Table has two disadvantages: each element must be accessed by index and the length of the data must be determined. Map, on the other hand, cannot do the job by itself and requires Transpose or Thread. None are great tasks, but represent extra work. MapThread is conceptually ...


1

v = {3.26797, 4.07436, 5.12821, 5.42005}; m = {0.004, 0.00592,0.00836, 0.01060}; ListLinePlot[Table[{{0, 0}, {m[[i]], v[[i]]}}, {i, 1, 4}],Frame -> True]


1

v = {3.26797, 4.07436, 5.12821, 5.42005}; m = {0.004, 0.00592, 0.00836, 0.01060}; ListLinePlot[{{0, 0}, #} & /@ Transpose[{m, v}]]


0

You can set the colours with the option PlotStyle, for example: ListPlot[{data1, data2, data3, data4}, PlotRange -> Automatic, PlotStyle -> {Green, Red, Blue, Yellow}] This makes the first set green, the second one red, the third one blue, and the fourth one yellow. There are also other things you can change, e.g. the size of the points: ...


1

Some manual analyse first. (Currently I failed to think out a way to analyse this with Mathematica.) The envelope shows the region that the family of planes occupies, so if we can decide whether a point in space belongs to the family or not, we can draw the envelope. How to decide? We change the form of the equation a little: $$ (a+x)^2+(b+y)^2=x^2+y^2+z $$ ...


0

car = Graphics[{Scale[{RGBColor[0.25, 0.63, 0.85], Polygon[... Epilog -> {{Dashed, Line[{{x, 42}, {x, y}}], Line[{{20, y}, {x, y}}]}, {AbsolutePointSize[32], Inset[car, {x, y}]}}


6

A couple of ideas. Rendering is a problem with transparency and so many planes. Hence the need for "DepthPeelingLayers". {zsol} = Solve[2 a x + 2 b y - z + a^2 + b^2 == 0, {z}]; family = Graphics3D[ {Opacity[0.3], Darker@Red, Specularity[White, 10], EdgeForm[Directive[Opacity[0.25], Red]], Table[InfinitePlane[{x, y, z} /. zsol /. Thread[{x, y} ...



Top 50 recent answers are included