# Tag Info

27

The easiest way to do this is if you have a PDB file, then it's as easy as using Import. Here are a few examples from the RCSB's Protein Data Bank. To get the URLs, find a page for a given sequence or protein and right-click on the link next to "DOI:" and copy the link. Import[#, "PDB"] & /@ {"http://files.rcsb.org/download/5ET9.pdb", ...

18

There are several important things about the way computer systems represent real numbers, which most of the time can be blithely ignored, just like the safety of bridges in the United States. One important thing is that numbers are discrete. With regular machine precision (double precision), the mantissa has 53 bits, which provides a lot of resolution. ...

18

Below is an animation that tips a proton precessing in the presence of a static B0 magnetic field from the z direction into the x-y plane with a 90 degree B1 pulse and attempts to explain the rotating frame. Unfortunately it is way too long to put into an answer but I have uploaded the notebook using Halirutan's SE Uploader tool. The notebook was built for ...

17

Here is a simple modification of the original code in the question that seems to do what's desired: curve[t_] := {Cos[2 Pi*t]/Cosh[Cot[Pi/4]*t], Sin[2 Pi*t]/Cosh[Cot[Pi/4]*t], Tanh[Cot[Pi/4]*t]}; lineSegment[t_] := ParametricPlot3D[curve[t1], {t1, -0.001, t}, PlotRange -> {-1, 1}, PlotStyle -> {Thick, Red}]; sphere = With[{w = 1.2}, ...

16

This was supposed to be a comment to Jason's answer, but it got a bit long. But wouldn't it be cool if you could just input a DNA sequence and have a plot? ... take that little snippet and paste it into the form on this site, then you can download a PDB file to import... By looking through the source of the make-na server form, I was able to figure out ...

15

This is a motivating post. I have made no effort to deal with intersection <4 pts. I post only illustrative examples. The centre of the circle is the intersection of perpendicular bisectors of chords. f[a_, b_, c_, d_] := Module[{e1 = a x^2 + b, e2 = c y^2 + d, s, p, l, ln, ctr}, s = Solve[{x, e1} == {e2, y}, {x, y}, Reals]; p = {#, a #^2 + b} ...

12

The trick here is to use the plotting function to generate the mesh lines, but there is no way to apply a ColorFunction for a MeshStyle - mesh lines need to have a single color. So we extract the mesh lines, break them up into pieces, and then apply the color function to them. This could be more efficient if I didn't use Normal but the code would be much ...

11

There appears to be a bug, not in Integrate or in BesselK, but in the vertical-axis Ticks of LogLogPlot. Consider the simple case, LogLogPlot[Exp[x], {x, 10^-10, 1}, PlotRange -> All] as it should be. However, LogLogPlot[Exp[x], {x, 10^-10, 1}, WorkingPrecision -> 50, PlotRange -> All] In fact, any value of WorkingPrecision except ...

10

MeshShading Plot[Sin[x], {x, 0, 2 Pi}, MeshFunctions -> {# &}, Mesh -> {{Pi/2}}, MeshShading -> {Red, Directive[Dashed, Blue]}, PlotStyle -> Thick] Two piecewise functions Plot[{ConditionalExpression[Sin[x], x <= Pi], ConditionalExpression[Sin[x], x >= Pi]}, {x, 0, 2 Pi}, PlotStyle -> {Directive[Thick, Red], ...

10

First answer (extended comment actually) You have to define better your objective function. For example, the following works: ClearAll[mat, minev] SeedRandom[1] rm = RandomInteger[10, {40, 40, 3}]; mat[t_] := N[rm.{1, t, t^2}]; minev[t_?NumericQ] := First@Eigenvalues[mat[t], -1]; Take[Table[minev[t], {t, 0, 1, .01}], 3] (* {-0.864071 - 1.30548 I, ...

10

Code phasePortrait[f_, {{xmin_, xmax_}, {ymin_, ymax_}}] := Plot[ f[x], {x, xmin, xmax}, Frame -> True, PlotStyle -> Directive[Black, Thick], ImageSize -> 500, PlotRange -> {{xmin, xmax}, {ymin, ymax}}, Epilog -> {getMarkers[f], getArrows[f, {xmin, xmax}]} ] right = Triangle[{{2, 0}, {-1, 1}, {-1, -1}}]; left = Triangle[{{-2, 0}, ...

9

This is very similar to Quantum_Oli's answer, but I will post it anyway. It use's a modified version of Jens's plotGrid function to do the work of combining the plots. The function is imported from a pastebin to save space here, << "http://pastebin.com/raw/tmMYLyMh"; hist = Show[ Plot[140 PDF[SmoothKernelDistribution[#], x] & /@ {data1, ...

9

MeshFunctions are useful here. Plot[{Sin[x]^2, Sin[10 x]^2}, {x, 0, 5}, PlotStyle -> {Red, Blue}, Mesh -> {{0}}, MeshFunctions -> {Sin[#]^2 - Sin[10 #]^2 &}, MeshStyle -> Green]

8

Histogram does not support a grouped ChartLayout. Hence the workaround using BarChart: I've arranged the 'histogram' into a bar chart so that the data can be displayed side by side. An alternative to using BarChart with "Grouped" layout is to use a custom ChartElementFunction to produce the desired Histogram layout: ClearAll[groupedHistogram] ...

8

How can I constrain the locator to stay within the region defined by RegionPlot? You can check if locator's coordinates fulfill the condition defining your region. It can be done with the second argument of Dynamic if you introduce Locator explicitly. Take a look at line with Locator[Dynamic[p, With[{... A strange behavior occurs whenever the left ...

8

You have a list of plots that you have defined already, all using the default color, (Evaluate[Symbol["plt" <> IntegerString[#]]] = Plot[# x^2, {x, -3, 3}]) & /@ Range[7]; Show[{plt1, plt2, plt3, plt4, plt5, plt6, plt7}] Boy that doesn't look right, so let's see if we can change that. Changing the color on any one plot is easy, plt1 /. ...

8

Is there a way to get coordinate of just a particular point? You can convert Line into the corresponding set of Points each of which will be a Button which Prints the coordinates of that Point when you click on it (try this!): plot = BodePlot[1000/((1 + s/10^3)*(1 + s/10^6))]; plot /. Line[pts_] :> Map[Button[Point[#], Print[#]] &, pts, {-2}] ...

8

working with Texture: Wig[n_, x_, y_] := (1/Pi) Exp[-(x^2 + y^2)] (-1)^n LaguerreL[n, 2 (x^2 + y^2)]; mx[n_, x_] := Sqrt[2/Pi] (1/(n! 2^n))*Exp[-2 x^2] HermiteH[n, Sqrt[2] x]^2; my[n_, y_] := Sqrt[2/Pi] (1/(n! 2^n))*Exp[-2 y^2] HermiteH[n, Sqrt[2] y]^2; p2d = Plot[mx[3, x], {x, -3.5, 3.5}]; range = {{-3.5, 3.5}, {-3.5, 3.5}, {-1/2, 1/2}}; poly = { ...

7

It is indeed possible, although not necessarily straightforward. The method I present below gives a pretty robust and accurate way of lining up plots, the downside is a little bit of code and having to specify a few different options. I'm used to it, it works. The key is that by specifying the ImageSize, and the Left and Right components of the ImagePadding ...

7

Rather than Show, you can use Prolog + Inset with Scaled: Plot[ 140 PDF[SmoothKernelDistribution[#], x] & /@ {S086, T086, X086}, {x, 0, 100}, Evaluated -> True, PlotStyle -> { {Thickness[0.01], RGBColor[0.23, 0.42, 0.63]}, {Thickness[0.01], RGBColor[0.29, 0.53, 0.80]}, {Thickness[0.01], RGBColor[0.62, 0.73, 0.88]}}, Frame -> ...

7

The following is a universal solution which extracts RGB color values assigned to the Line primitives of a plot generated by built-in plotting functions of Mathematica 10: Cases[fplot, {___, c_Directive, __Line} :> ColorConvert[c, RGBColor], Infinity] // InputForm {RGBColor[0.368417, 0.506779, 0.709798, 1.], RGBColor[0.880722, 0.611041, 0.142051, ...

7

Area As described on this page, the area enclosed by a polar curve is given by $$A = \int_\alpha^\beta \frac{r(\theta)^2}{2} \mathrm{d}\theta$$ In your case this is, Integrate[Sin[2 θ]^2/2, {θ, 0, π}] N@% (* π/4 *) (* 0.785398 *) You can get this same answer using Region functionality by first making a RegionPlot, converting it to a MeshRegion and ...

7

How about this: f[x_] := Sin[x] Plot[{#1, #2, #1 + #2} &[f[x], f[2 x]], {x, 0, 4}] Strangely enough, this solution is slower that expected: f[x_] := NIntegrate[Sin[1/y^2], {y, -x, x}] (*slow function*) AbsoluteTiming[Plot[{f[x], f[2 x], f[x] + f[2 x]}, {x, 0, 1}]] (*naïve approach*) AbsoluteTiming[Plot[{#1, #2, #1 + #2} &[f[x], f[2 x]], {x, 0, ...

7

One way of coding the iterations may be defined as follows. The function CollatzFractal01[z0] returns a list {Abs[z],iter}, where Abs[z] is the final value of z, and iter is the number of iterations required to escape the bound of Abs[z]>200. Use compilation and parallelisation for speed. CollatzFractal01 = Compile[{{z0, _Complex, 0}}, Module[{iter = ...

7

You can use Part (also written [[...]]) to get what you want. For example, myList= Table[{i, i}, {i, 1, 20}]; ListPlot[myList] ListPlot[myList[[1;;-1;;2]]] (* every second point *) ListPlot[myList[[1;;-1;;3]]] (* every 3rd point*)

6

I'm not sure what kinds of calculations you'll want to do on the intersection line; but to get a sample of points on the intersection line, you could use DiscretizeRegion and MeshCoordinates: f[x_, y_, z_] = x^4 + y^4 + z^4 - 1; g[x_, y_, z_] = x - 2 y + z - 2; ContourPlot3D[{f[x, y, z] == 0, g[x, y, z] == 0}, {x, -2, 2}, {y, -2, 2}, {z, -2, 2}, ...

6

Well, you can use DiscretizeGraphics and RandomPoint to achieve what you want: P0 = ContourPlot3D[Φeff == E0, {x, -rm, rm}, {y, -rm, rm}, {z, -rm, rm}, Mesh -> None, Lighting -> None]; Note the Lighting -> None option, this is to circumvent a bug in DiscretizeGraphics that the good people at Wolfram refuse to fix. gg = ...

6

This version works: rl = {ρ[z_, ϕ_] :> 1/5 Sqrt[25 - 25 z^2 + 10 Sin[5 ϕ] + Sin[5 ϕ]^2]}; Manipulate[PolarPlot[Evaluate[ReplaceAll[ρ[z, ϕ], %]], {ϕ,0, 2 Pi}], {z, -1, 1}] Manipulate[PolarPlot[Evaluate[ReplaceAll[ρ[z, ϕ], rl]], {ϕ,0, 2 Pi}], {z, -1, 1}] The main change is in the way the rule is defined as a $RuleDelayed$ instead of $Rule$.

6

More of an extended comment here, but it is clear that ListPlot must use a different interpolation function than is available via Interpolation. We can get a very close approximation by Janus's answer here and amending the Method option. The idea is that ListPlot performs an parametric interpolation on the x and y axes separately. data = {{1., 5827.}, ...

6

EDIT (incorporating comments by @J.M.: DistanceFunction->dis and pre-computation of nearest function): This is not efficient. Just rewriting metric (apologies for errors). In the following I used ContourPlot but DensityPlot could be used. dis[a_, b_] := Abs[ArcCosh[1 + 2 ( a - b).(a - b)/((1 - a.a) (1 - b.b))]] vh[n_] := Module[{p = ...

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