Tag Info

New answers tagged

1

One can workaround this issue by using nested lists instead of associations. TimelinePlot[GatherBy[ Rule @@@ Transpose@{DateList /@ AllDate, AllVersion}, StringTake[Last@#, 1 ;; 2] & ]]


2

It appears that TimelinePlot doesn't handle multiple Associations very gracefully. One imperfect workaround is to use Show tlp1 = TimelinePlot[{Entity["HistoricalEvent", "WorldWar2"], Entity["HistoricalEvent", "VietnamWar"]}]; tlp2 = TimelinePlot[{Style[{Entity["HistoricalEvent", "WorldWar1"], Entity["HistoricalEvent", "KoreanWarBegins"]}, Red]}]; ...


0

EDIT: Added legends for max, min, and saddle points. pts = { {1.5, 1.5}, {1.5, -1.5}, {2.5, 0}, {2.5, 1.94}, {2.5, -1.94}, {-2.5, 0}, {2, 2}, {-2, 2}, {2, -2}, {-2, -2}, {2.5, 2}, {-2.5, 2}, {-2.5, -2}, {2.5, -2}}; f[x_, y_] = y^4 - 3 x y^2 + x^3; The function is symmetric in y f[x, y] == f[x, -y] True FindMaximum[{f[x, y], -2.5 ...


1

I do not experience much difference in performance of StreamPlot between versions 7 and 10.1 with the example given. In fact 10.1 is faster than 7.0 at 0.22 seconds versus 0.28 seconds. (Times for generation and rendering combined.) However I can confirm the EvaluationMonitor steps reported, therefore I think this is a change to EvaluationMonitor rather ...


0

Changing ImageSize with one number changes both the height and width of the figure. In order to preserve the height across differen datasets (which is in retrospect one aspect I want) I have found a reasonable solution that involves setting the Y aspect of ImageSize to a fixed value and the X aspect to a value based on the number of nodes at the bottom of ...


4

You can also use MeshShading: Plot[Cos[t], {t, 0, 2 Pi}, PlotStyle -> Thickness[0.02], Ticks -> {{0, Pi, 2 Pi}, {-1, 0, 1}}, MeshFunctions -> (#1 &), Mesh -> {{Pi}}, MeshShading -> {Red, Opacity[0.2, Red]}, MeshStyle -> None]


3

Plot[Cos[θ], {θ, 0, 2 Pi}, PlotStyle -> Thickness[0.02], AxesLabel -> {"θ", "Energie"}, ColorFunction -> Function[{x}, Piecewise[{{Opacity[1, Red], 0 <= x <= π}, {Opacity[.2, Red], π < x <= 2 π}}]], Ticks -> {{0, Pi, 2 Pi}, {-1, 0, 1}}, ColorFunctionScaling -> False]


5

You could use Epilog, something like: pts = {{1.5, 1.5}, {1.5, -1.5}}; ContourPlot[{y^4 - 3 x*y^2 + x^3}, {x, -2.5, 2.5}, {y, -2, 2}, Contours -> {Automatic, 50}, BoundaryStyle -> Directive[Red, Thick], ContourShading -> None, Axes -> True, AxesLabel -> {x, y}, PlotRange -> {{-3, 3}, {-2.5, 2.5}}, LabelStyle -> Directive[Blue, ...


1

The problem lies with using Sphere (or Circumsphere), which are actually surfaces rather than solids. Instead use Ball: a = 1; p0 = {0, 0, 0}; p1 = a {0, 0, Sqrt[2/3] - 1/(2 Sqrt[6])}; p2 = a {-(1/(2 Sqrt[3])), -(1/2), -(1/(2 Sqrt[6]))}; p3 = a {-(1/(2 Sqrt[3])), 1/2, -(1/(2 Sqrt[6]))}; p4 = a {1/Sqrt[3], 0, -(1/(2 Sqrt[6]))}; cs = Circumsphere[{p1, p2, p3, ...


6

I would prefer to use the "GeoImage" styling, because you can use other projections when using it. Let's say you have data for the whole world in a matrix: data = Table[ Sin[x Degree] Sin[y Degree], {y, -90, 90}, {x, -180, 180}] Then you use ListDensityPlot: den1 = ListDensityPlot[data, AspectRatio -> 1/2, Frame -> None, PlotRangePadding ...


1

Either calculate correct / specific coordinates to effect a desired spacing, or use ImageSize option, e.g. GraphPlot[graphNodes["Lys"], VertexLabeling -> True, VertexCoordinateRules -> nodeCoordinates["Lys"], ImageSize -> 550]


2

The 1-st argument given to Row must be a list. Manipulate[ Graphics[{ Black, Arrow[{{-5, 0}, {5, 0}}], Arrow[{{0, -5}, {0, 5}}], Blue, Arrow[{{0, 0}, arrowA}], Arrow[{{0, 0}, arrowB}]}], {{arrowA, {3, 3}}, Locator}, {{arrowB, {-3, 3}}, Locator}, FrameLabel -> {{None, None}, {None, Row[{"θ = ", ...


-1

My code is: RegionPlot3D[ 0 <= x^2 + y^2 <= 4 && 0 <= z <= 3, {x, -2, 2}, {y, -2, 2}, {z, 0, 3}]


4

Use RegionPlot3D for 3D inequalities. You should get a cylinder. RegionPlot3D[ 0 <= x^2 + y^2 <= 4 && 0 <= z <= 3, {x, -3, 3}, {y, -3, 3}, {z, -1, 4}, PlotPoints -> 40] Increase the PlotPoints for a better quality mesh.


3

Here are a couple of approaches: using ParametricPlot Quiet@ParametricPlot[{Graham[10^-9, t], t}, {t, 0, 1}, AspectRatio -> Full] Let p be your plot and just extract points: ListPlot[Reverse /@ First[Cases[p, Line[x__] :> x, -1]], Joined -> True]


1

Following Mr. Wizard's suggestions, I'll offer the following comment to the OP's situation in an attempt to summarize the communal wisdom on this point. The great difficulty in the OP's question is in timing the rendering process, which takes place in the Front End and vastly overshadows the calculation time in the original problem. Unfortunately, there is ...


13

Please see the Utility function section for a concise summary. An arbitrary density plot for the example: den = DensityPlot[Sin[x] Sin[y], {x, -180, 180}, {y, -90, 90}] : Extract the graphics primitives from the density plot: prim = First @ Cases[den, Graphics[a_, ___] :> a, {0, -1}, 1]; Plot them directly with GeoGraphics while setting the ...


4

Figured it out. For some unknown reason, GridLines created with DateRange and Quantity magically export in .eps. GridLines -> {DateRange["2016", "2019", Quantity[3, "Months"]], None} I have no idea why this form works while Automatic does not.


2

sol = DSolve[x'[t] == -x[t], x[t], t]; f = x[t] /. sol[[1]] /. C[1] -> x1; p1 = ContourPlot[ Evaluate[Table[x == f, {x1, {-.1, .1, 1, -1}}]], {t, -5, 5}, {x, -2, 2}]; points = Join @@ (Table[{i, j}, {i, -5, 5}, {j, -2, 2, .5}]); line = Rotate[{Gray, Line[{# - {.3, 0}, # + {.3, 0}}]}, ArcTan[-#[[2]]]] & /@ points; p2 = Graphics[{line, ...


1

I used the answer here and set the independent variable t as first argument. It looks now close to your book f[t_, x_] := -x StreamPlot[{1, f[t, x]}, {t, -2, 2}, {x, -.5, .5}, Frame -> False, Axes -> True, AspectRatio -> 1/GoldenRatio]


2

EDIT this isn't what OP had in mind, but I'll let the answer linger for the related and linked questions. EDIT 2 to provide a very brief answer for the intended question: ParametricPlot[{x, y Sin[x]}, {x, 0, 6}, {y, 0, 1}, PlotStyle -> Red, ColorFunctionScaling -> False, ColorFunction -> (Blend[{Red, White}, Abs@#2] &)] Old answer ...


3

The spurious context change is a bug and can be avoided by turning the Suggestions Bar off. The predictive interface tries a number of evaluations behind the scenes, each wrapped in TimeConstrained so they don't take too long. Depending on the input, some of these predictions may end up using (and autoloading) other functionality. The context path ...


1

You could sample by yourself dataSample= (E^(-0.5 #) NIntegrate[Cos[t] E^(Cos[t] + 0.5 t), {t, 0, #}] &) /@ Range[0, 40, .1] ListLinePlot[Thread@{Range[0, 40, .1], dataSample}]


5

To flesh out GuessWho's suggestion: sol[t_] = NDSolveValue[{Cos[t] E^(Cos[t] + 0.5 t) == f'[t], f[0] == 0}, f[t], {t, 0, 40}] Show[ Plot[E^(-0.5 x) NIntegrate[Cos[t] E^(Cos[t] + 0.5 t), {t, 0, x}], {x, 0, 40}] Plot[E^(-0.5 t) sol[t], {t, 0, 40}, PlotStyle -> {Red, Dashed}] ] The second plot is about 300 times faster than the first one.


6

data = Transpose[{RandomReal[{0, 1}, 10000], RandomReal[{0, 10}, 10000]}]; Legended[Graphics[{Function[{x, y}, {ColorData["Rainbow"][ Norm[{x, y/10} - {0.5, 0.5}]/Sqrt[0.5]], Point[{x, y}]}] @@@ data, {Red, PointSize[0.04], Point[{0.5, 5}]}}, AspectRatio -> Full, Frame -> True], BarLegend["Rainbow"]]


8

data3 = Style[{##}, ColorData["Rainbow"][Abs[(#1 - 0.5)] + Abs[1/10 (#2 - 5)]]] & @@@ data; Legended[ListPlot[data3, PlotStyle -> PointSize[0.01]], BarLegend["Rainbow"]] Update for your question in the comment: The color function ColorData["Rainbow"] ranges from 0 to 1 so the value has to be used within this range. Abs function ...


2

Just to illustrate versatility of Mathematica: Plot3D[2 x - y, {x, -2, 2}, {y, -2, 2}, RegionFunction -> Function[{x, y, z}, x^2 + y^2 < 4]] f = TransformedField["Cartesian" -> "Polar", 2 x - y, {x, y} -> {r, t}]; j = Simplify[Det[Outer[D[#1, #2] &, {r Cos[t], r Sin[t]}, {r, t}]]]; Integrate[f j, {r, 0, 2}, {t, 0, 2 Pi}] where the ...


2

While belisarius's comment answers the question, an arguably better way to achieve these is to use regions. For example, the plot is less choppy and there is less rounding error when integrating (for this example at least). (* without regions *) f[x_, y_] := 2*x - y (* choppy plot *) Plot3D[f[x, y], {y, -2, 2}, {x, -1*Sqrt[4 - y^2], Sqrt[4 - y^2]}] (* ...


5

The ScalingFunctions option is officially documented for BarChart and similar functions, but it actually works with the *Plot functions as well! See Belisarius's comment here. In your case, you could use it to your advantage: data = Table[{10^-k, 10^(-2 k)}, {k, 5}] ListPlot[ data, ScalingFunctions -> {{-Log10[#] &, 10^-# &}, "Log"}, ...


0

Manipulate[ Graphics3D[Tetrahedron[], ViewPoint -> 5 {Cos[\[Theta]] Sin[\[Phi]], Sin[\[Theta]] Sin[\[Phi]], Cos[\[Phi]]}], {\[Theta], 0, 2 \[Pi]}, {\[Phi], 0, \[Pi]}]


0

You can strip the frame and padding from the contour plot and the OP's approach seems to work. cp5 = ContourPlot[Sin[x]^2 + 2 y, {x, 0, 2 π}, {y, 0, 4}]; values = {{0, 0, 0.2`}, {0, 1, 0.3`}, {0, 3.5`, 0.43`}, {0, 4, 0.2`}, {(2 π)/3, 0, 0.38`}, {(2 π)/3, 1, 0.45`}, {(2 π)/3, 3.5`, 0.25`}, {(2 π)/3, 4, 0.1`}, {(4 π)/3, 0, 0.37`}, {(4 π)/3, 1, 0.4`}, ...


-1

Monitor[ListLogLogPlot[Table[{n, y = n RandomReal[]}, {n, 1, 10^5}]], ProgressIndicator[y, {1, 10^5}]]


0

I believe you've mistyped the differential equation as well by using u'[t] instead of u[t]. It should probably be: In which case you get an answer which should match your book: de4 = {u''[t] + u[t] == .5 Cos[.8 t], u[0] == 0, u'[0] == 0} soln5 = Simplify[DSolve[de4, u[t], t]] Plot[u[t] /. soln5, {t, 0, 60}, PlotRange -> {-3, 3}] The solution ...


2

You can use Polygon to get this effect. If you use ListPointPlot3D as well, you have easy access to the axes. a = Table[{j, i, i*Exp[-(j - 6)^2/(4)]}, {i, 1, 12}, {j, 1, 10}]; c = ColorData[97][#] & /@ Range[1, Length@a]; Show[ ListPointPlot3D[a, PlotStyle -> c], Graphics3D[{#1, Polygon[#2]}] & @@@ Transpose@{c, a} ] Which gives Or you ...


0

First of all, you should not use 0.5 and 0.8 when you are looking for an analytic solution. Then, when you use u[t] in your equation, why do you use y[t] in the plot? This will never work and you could have found out by replacing Plot with e.g. blot which is an undefined function plot[Evaluate[y[t] /. solution5], {t, 0, 60}, PlotRange -> {-2, 2}] (* ...


4

The "Details" section of the documentation for ViewPoint states that you can use high values for this option to reduce the distortion due to perspective, which is the effect that bothers you. However, this is the equivalent of looking at your plot from really far away, so you should then drastically reduce the value of ViewAngle (i.e. the "zoom") to include ...


2

Here is what I think is going on with the second argument to ContourLabel. Everything starts with the fact that ContourPlot has Attribute of HoldAll, which means that all the options you give it can be parsed in a non-standard way before being evaluated. This seems to be happening in the ContourLabels option: it is scanned for the appearance of Tooltip, ...


3

As mentioned in my comment on Mahdi's answer, it is generally not advisable to use Module within Manipulate - http://mathematica.stackexchange.com/a/80324/1952 gives a good explanation of why. I have refactored your code into a Manipulate that uses Initialization, as advised by Mahdi it is necessary to change your definition of f to use SetDelayed rather ...


2

Here is a quick and somewhat dirty solution. Legended[ Show[PIC1, PIC2, PIC3], SwatchLegend[ {Yellow, Blue, Green}, {"Cos[x] Cos[y]", "-(x-Pi/2) (y+Pi/2)", "(x-Pi/2) (y+Pi/2)"}]]


3

The solution below seems to work for me from within ContourPlot, using the ContourLabels option: ContourPlot[ Exp[-x^2 - y^2], {x, 0, 2}, {y, 0, 2}, PlotRange -> Full, Contours -> 10^Range[-4, 0, 0.1], ContourLabels -> {None, Tooltip[#3, DisplayForm[SuperscriptBox[10, Log[10, #2]]]] &} ] The key piece of information is the fact that ...


8

Thanks to the links and tips provided by Mr.Wizard I found the answer I was looking for, with a combination of EvaluationMonitor and the undocumented Bag functionality. Two problems with the code I found: For some reason updating the Bag object doesn't trigger the evaluation of a Dynamic expression containing it. I had to add another variable which ...


3

Hat-tip to DrMajorBob for this handy workaround: ContourPlot[ Exp[-x^2 - y^2] , {x, 0, 2}, {y, 0, 2} , PlotRange -> Full , Contours -> 10^Range[-4, 0, 0.1] ] /. {Tooltip[expr_, tooltip_] :> Tooltip[expr, DisplayForm[SuperscriptBox[10, Log[10, tooltip]]] ]} This uses the fact that Tooltip'd expressions have a very ...


0

Here is a variation of wxffles' method using Indexed rather than undocumented behavior of Hold within Plot. Hold still works in v10.1 but I think this is more likely to remain working; note that sadly kguler's answer no longer works due to changes in undocumented behavior. f[x_?NumericQ] := {x, x^2, Sin@x, Cos@x, ArcTan[x]} Plot[Indexed[f[x], #2] & ...


0

DEGREE = 2; x0 = 1; y0 = \[Pi]; f = x^2*Sin[(x*y)/2]; g = Normal@Series[f, {x, x0, DEGREE}, {y, y0, DEGREE}]; $$ g(x,y)=(x-1)^2 \left(\left(\frac{\pi ^2}{64}-\frac{3}{4}\right) (y-\pi )^2-\frac{3}{4} \pi (y-\pi )-\frac{\pi ^2}{8}+1\right)+(x-1) \left(-\frac{1}{2} (y-\pi )^2-\frac{1}{4} \pi (y-\pi )+2\right)-\frac{1}{8} (y-\pi )^2+1 $$ Plot3D[#, ...


2

I find your question enigmatic but perhaps this is something useful: f[x_?NumericQ] := Rationalize[x, 0.1]^2 - 2 Plot[f[x], {x, -2, 2}] However I suspect you probably want something else. Have you looked at Convergents?


3

You need to specify dx as a function of n, or replace dx definition directly in Manipulate. Functional Form of dx Clear[f, a, b, n, dx]; f[x_] := x^2; a = 0; b = 1; dx[n_] := (b - a)/n; Manipulate[ Show[Plot[f[x], {x, a, b}, PlotStyle -> Thick, AxesLabel -> {"x", "y"}], Graphics[{Table[{Opacity[0.05], EdgeForm[Gray], Rectangle[{a + i ...


2

Manipulate[a = Plot[x, {x, 0, 1}]; b = Plot[1 - z, {z, 0, 1}]; Show[If[cond1 == 1, a, Graphics[]], If[cond2 == 1, b, Graphics[]], Axes -> (cond1+cond2>=1), PlotRange -> {{0, 1}, {0, 1}}, AspectRatio -> 1/GoldenRatio], Grid[{{Control[{{cond1, 1, ""}, {0, 1}}], "a"}, {Control[{{cond2, 1, ""}, {0, 1}}], "b"}}]] Change Axes -> ...


6

ClearAll[tF] SeedRandom[10] n = 100; sample = Sort[Sin[Pi*RandomVariate[UniformDistribution[{0, 1}], n]]]; dist = EmpiricalDistribution[sample]; Use tF to define a custom ProbabilityDistribution: tF[y_] := 2/Pi*ArcSin[y] tfdist = ProbabilityDistribution[{"CDF", tF[x]}, {x, 0, 1}]; Row[Plot[Evaluate[#[tfdist, x]], {x, 0, 1}, Filling -> Axis, ...


5

Also fixing your code... n=30; TF[y_] = 2/Pi*ArcSin[y]; SeedRandom[10]; sample = Sort[Sin[Pi*RandomVariate[UniformDistribution[{0, 1}], n]]]; d = EmpiricalDistribution[sample]; EF = CDF[d, x]; To get the max. difference, I tried NMaximize and others, but didn't work. The one that worked for me was this: X = NArgMax[{Abs[EF - TF[x]], 0 < x < 1}, x] ...


2

You had a few oddities in your syntax. If you want to define TF as a function of $y$, you had best use SetDelayed (:=) instead of set. Take a look at the documentation of search this site on this point. The constant $\pi$ is Pi in Mathematica, note the uppercase letter. $n$ was not defined in your code. I am arbitrarily using $100$ data points in the ...



Top 50 recent answers are included