Tag Info

Hot answers tagged

8

Perhaps a bit more elegant than Sjoerd's approach: data = Sort @ data; (* address Sjoerd's concern *) pts = { data, MinimalBy[data, Last, 1], MaximalBy[data, Last, 1] }; DateListPlot[pts, Joined -> {True, False, False}, PlotStyle -> {Automatic, Red, Green} ]


7

A quick and dirty way to do this is to pad the image with pixels of some inoffensive color, so that the actual meaningful part of the image gets mapped to a smaller portion of the sphere: image = Import["ExampleData/ocelot.jpg"]; {width, height} = ImageMeasurements[image, "Dimensions"]; image = ImagePad[image, {{2 width, 2 width}, {height, height}}, White]; ...


6

Update: SeedRandom[123] d1 = BinormalDistribution[.75]; r = RandomVariate[d1, 20]; hg = Histogram3D[r, Automatic, "PDF", ChartStyle -> Opacity[.35]]; sh = SmoothHistogram3D[r, Automatic, "PDF", BoundaryStyle -> None, PlotStyle -> None, Mesh -> {{{.03, Directive[Thick, Orange]}, {.11, Directive[Thick, Red]}}}]; Row[{Show[hg, sh, PlotRange ...


5

I might be missing the point of the question but I think you just need _?NumericQ: ClearAll[CountingFcn] CountingFcn[dat_, r_?NumericQ] := Count[dat, u_ /; u < r]; This prevents the evaluation of the function until r is numeric. Now: PlotCountsEval[SampleDats, {0, 13}] Reference: PatternTest, NumericQ


5

I am answering my own question as I have discovered an undocumented Mathematica feature which does exactly what I wanted. While playing around with some plot options, I discovered that setting PlotTheme->"Monochrome" had precisely the effect that I wanted - it displayed only some of the edges of the box. So I started digging, and running ...


4

Most of the desired plot can be achieved using only options Mesh and MeshFunctions. Plot[{Sin[x], Cos[x]}, {x, -0.01, 4.01}, MeshFunctions -> {If[Abs[Sin[#] - #2] < .001 && Abs[Cos[#] - #2] > .0001, Sin[# 2 Pi] + 1, Sin[# Pi] - 1] &}, Mesh -> {{{1, Directive[Red, PointSize[0.02]]}, {-1, ...


4

You can change the legend using the LegendMarkers option to an explicitly constructed LineLegend. The points are a bit of a hack, but you can always explicitly create them as an Epilog collection of points. I couldn't work out which colour scheme is the default in version 10, so I used the first indexed colour scheme, which replicates the default styles used ...


4

Haven't aimed for efficiency or elegance but for 'straightforwardness' data = Sort@data; (* just to make sure the dates are always sorted *) max = Max@data[[All, 2]]; min = Min@data[[All, 2]]; maxPos = FirstPosition[data[[All, 2]], max] // First; minPos = FirstPosition[data[[All, 2]], min] // First; maxPlotPos = MapAt[AbsoluteTime, data[[maxPos]], 1]; ...


4

Here is an approach with Inset. From the documentation: Inset[obj,pos,opos,size,dirs] represents an object obj inset in a graphic... specifies that the inset should be placed at position pos in the graphic... aligns the inset so that position opos in the object lies at position pos in the enclosing graphic... specifies the size of the inset in ...


4

myData = {{2, 1, #}, {1, 1, 0}} & /@ Table[1/(n + 2) + .2 RandomReal[], {n, 1, 15}]; SectorChart3D[myData, BoxRatios -> {1, 1, 1}, ColorFunction -> Function[{x, y, z}, Hue[z]], ColorFunctionScaling -> False]


4

Combine Plots with Show, and remember to use PlotRange -> All: Show[ Plot[x, {x, 0, 1}, PlotStyle -> Blue], Plot[x^2, {x, 1, 2}, PlotStyle -> Red], PlotRange -> All] Another option, as Karsten7. stated, is to use piecewise functions with non-numeric default value outside their domain: Plot[ {Piecewise[{{x, x < 1}}, Null], ...


3

Is this what you want? data = { {"a", "b", 1, 0.5, 4}, {"x", "y", 10, 100, 4.21} }; numericdata = data; numericdata[[All, 1]] = Range[1, Length[numericdata]]; (**) numericdata[[All, 2]] = Range[1, Length[numericdata]]; (**) ListPointPlot3D[ { numericdata[[All, {1, 2, 3}]], numericdata[[All, {1, 2, 4}]], numericdata[[All, {1, 2, 5}]] }, ...


3

Edit, based on the added info in the question: data1 = RandomVariate[BinormalDistribution[.75], 10]; distribution1 = SmoothKernelDistribution[data1]; data2 = RandomVariate[BinormalDistribution[.75], 10]; distribution2 = SmoothKernelDistribution[data2]; ContourPlot[ {PDF[distribution1, {x, y}] == 10^(-2), PDF[distribution2, {x, y}] == ...


3

Lest we forget the old-fashined ways: extremes=data[[Ordering[# data[[All,2]],1][[1]]&/@{-1,1}]]; DateListPlot[{data,##&@@(List/@extremes)}, Joined -> {True,False,False}, BaseStyle -> PointSize[Large], PlotStyle -> {Gray,Red, Green}, PlotLegends -> {"data", "max","min"}] Note: If data is not sorted, we need to sort it first ...


3

Do you care about maxima and minima or peaks? If peaks then you could use FindPeaks but this is only available for M10+. Note also that FindPeaks only handles regularly spaced TimeSeries - hence the use of TemporalRegularity: data = TimeSeries[{{{2015, 3, 25}, 130}, {{2015, 3, 26}, 132}, {{2015, 3, 27}, 132}, {{2015, 3, 30}, 133}, {{2015, 3, 31}, 132}, ...


3

testGraph = ListPlot3D[data, Mesh -> None, InterpolationOrder -> 3, ColorFunction -> "SouthwestColors", AxesLabel -> {Rotate["Number of Processes", - 20 Degree], Rotate["Number of Operations", 60 Degree], Rotate["Time (ms)", 95 Degree]}, ImageSize -> 450]


3

First our definitions: f[x_, y_] := Max[2 - (y - 1)^2, x + 1 - (y - 2)^2] Γ = Interval[{0, 4}] The definition of $G(x)$ is (adjusting the notation slightly): $$ \{y\in\Gamma:\forall_{z\in\Gamma}f(x,y)\geq f(x,z)\} $$ In English, this is The set of $y$ (in $\Gamma$) for which $f(x,y)$ is no less than $f(x,z)$ for any $z$ in $\Gamma$. We can make ...


3

Update: ClearAll[showF] showF[tr_: {10, 10}, rt_: {-Pi/4, {0, 0}}, opts : OptionsPattern[{Graphics, Graphics3D}]][g_] := Module[{head = Head[g], pr = PlotRange[g], transF=Composition[TranslationTransform[tr], RotationTransform[rt[[1]], rt[[2]]]]}, Module[{prim = If[head === Graphics3D, Cuboid, Rectangle] @@Transpose[pr], points = ...


3

Plot is not really for discrete results like this, though one can harangue it into doing so. Better to use DiscretePlot or ListPlot, e.g.: Table[CountingFcn[SampleDats[[j, All]], r], {j, 1, Length[SampleDats]}, {r, 0, 13}]; ListPlot[%, Joined -> True, InterpolationOrder -> 0, DataRange -> {0, 13}]


3

Update According to @xzczd in my comment: Simply removing the outermost braces will work, i.e. {0,0},{1,2},{5,3},{6,5}. Original Answer (0,0) (1,2) (5,3) (6,5) worked. To efficiently convert your lists to this form: convertlist[expr_] := StringReplace["(0,0) " <> ToString[expr], {"{{" -> "(", "}}" -> ")", "}, {" -> ") ("}] Comparing ...


3

The differential equation, its initial condition, and its boundary conditions are translationally invariant in space. Consequently, the solution must be independent of x and y. Indeed, solving the equations as given in the Question does give a spatially constant solution that oscillates in time. For instance, DensityPlot[Evaluate[Re[A[x, y, 10000]] /. ...


3

Something like this? Show[{Plot[PDF[NormalDistribution[], x], {x, -4, 4}, AxesLabel -> {None, "Z"}], Plot[PDF[NormalDistribution[], x], {x, 2, 4}, AxesLabel -> {None, "Z"}, Filling -> Bottom]}] The easiest for the label is to add them with the drawing tools


2

For the second part of your question (finding the envelope) we can use the argument from page 5 of these lecture notes. Basically the envelope is where two very close strings intersect each other. We can parameterize the string by: $$ \{x,y\} = \{x_1(t),y_1(t)\}(1-s) + \{x_2(t),y_2(t)\}s $$ Where the $\{x_i,y_i\}$ represent the two endpoints, $s\in ...


2

The second part of your question can be resolved as follows. First find the equation for any given line. y = k x + y0. Solve[{b == k * 0 + y0, 0 == k * a + y0, a + b == 2}, {k, y0, a}] {{k -> b/(-2 + b), y0 -> b, a -> 2 - b}} It is clear enough, that the bottom and leftmost boundaries are the x and y axes. Let's find the boundary on top. We ...


2

Here is an example. You have to be careful with the plot range so that the aspect ratio is just right, otherwise the figure is going to look skewed. transform = Composition[ TranslationTransform[{10, 5}], RotationTransform[45 Degree] ]; ListLinePlot[{ Table[transform@{x, Sin[x]}, {x, 0, 2 Pi, 0.1}], Table[{x, Sin[x]}, {x, 0, 2 Pi, 0.1}] }, ...


2

decibel is a relative unit. I'm pretty sure there is no implied standard reference in audio processing, (it looks like audiologists have a few go-to's e.g. dB HL, but I don't know what Audacity does). That said, you need a reference value. Since you're looking at FFT's the total power might be a good choice. Then decibels will tell you how strong a ...


2

Another possibility is to use PlotRangePadding. Lets take 2012rcampion's answer Plot[x^2, {x, 0, 1}, AxesOrigin -> {-1, 0}, PlotRange -> {{0, 1}, {0, 1}}, PlotRangePadding -> {2, 0}] You can change the padding range to see when your axes are appearing.


2

1. I doubt there is an easier way than what you did. One can wrap it up in a function: ClearAll[markerMesh]; SetAttributes[markerMesh, HoldAll]; markerMesh[Plot[fns_List, {x_, x1_, x2_}, opts : OptionsPattern[]], markerOpts : OptionsPattern[]] := Show[ Plot[fns, {x, x1, x2}, Evaluate@FilterRules[{opts}, Except[{Mesh}]]], ListPlot[MapThread[ ...


2

ParameticPlot is what you are looking for. With[{r = 1}, ParametricPlot[r {2 π t - Sin[2 π t], 1 - Cos[2 π t]}, {t, 0, 2}]]


2

I have changed so solution and vector plot match: Subscript[\[Tau], yz] = -\!\( \*SubscriptBox[\(\[PartialD]\), \(x\)]\(\[CapitalPhi][x, y]\)\); Subscript[\[Tau], xz] = \!\( \*SubscriptBox[\(\[PartialD]\), \(y\)]\(\[CapitalPhi][x, y]\)\); vp = VectorPlot[{Subscript[\[Tau], xz], Subscript[\[Tau], yz]}, {x, 0, 1}, {y, 0, 1}]; \[CapitalOmega] = ...



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