plotting – How can I style a Line like “Glassrectangle”?


Your privacy


By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.




plotting – How to recreate this complex iteration

I came across this image in a book Im reading:

enter image description here

(taken from Rational Iteration Complex Analytic Dynamical Systems from Steinmetz. I hope it is okay to share it here)

and I try to recreate it in Mathematica. I tried

JuliaSetPlot((9 + 2 z + 9 z^2)/20, z)

which gives a complete different picture.

enter image description here

I also tried to use

ColorFunction -> With({cf = ColorData("M10DefaultFractalGradient")}, cf@Sqrt(#3) &)

which doesn’t improve anything. So JuliaSetPlot might not be the right method. Do you have any suggestions?

plotting – Why PieChart Callout is so slow?

I was testing PieChart using the following random data before touching my own dataset and found the ChartLabels using the Callout function is so slow. I wonder why and is there anyway to improve its performance? I tried PerformanceGoal→"Speed" (learned from here) as the PieChart option, it seems to me not very effective. On my laptop, the following three ChartLabels option yield 0.204785, 15.0763, 48.0431 with AbsoluteTiming.

Generate data

SeedRandom(14);
list = RandomInteger({1, 100}, 300);
stats = Counts@list

Plot PieChart

PieChart(stats,ChartStyle->"Pastel",

ChartLabels->Placed(Keys@stats,"RadialCallout"),(*okay*)
ChartLabels->Callout(Keys@stats,Automatic),(*slow*)
ChartLabels->Callout(Row({Style(#((1)),Italic)," = ",Style(#((2)))})&/@rules,Automatic),(*too slow*)

ImageSize->Full)//AbsoluteTiming

rules used in the 3rd one.

rules=Normal@stats;

BTW, when I changed the Head to BarChart with the rest the same, it is faster. However, the Callout slow issue remained.

plotting – How can I assign mixed colors to each point in ListPlot?

I have this data which is in the form {{xi,yi,{ri,bi,gi}}} where xi and yi are the data and {ri,bi,gi} are the weight of red, black and green colors that coincide with each point {xi,yi}. To visualize this I used Blend to give the assigned color for each point as follows

colorbar(rd_, bk_, gr_) := Blend({Red, Black, Blue}, Rescale({rd, bk, gr}, {0, 1})) 

and then I tried this

    ListPlot(data((All, 1 ;; 2)), ColorFunction -> (colorbar(#((1)), #((2)), #((3)))) & /@ 
  data((All, 3 ;; 3))((All, 1)), ColorFunctionScaling -> False)

Now, this should show each point with the assigned color, but all points appear with the same color

enter image description here

How can I solve this, please?

plotting – How to plot a single column of data exported from a CSV file?

I am importing data from a CSV file using this code:

k = Import(“D:/MTU/Mathematica/data.csv”);

Once I have this data, I want to plot it as a scatterplot (I guess I use LinePlot for that). But I need the values from the data to be on the y-axis with the x-axis starting from 1 and increasing in increments of 1. How can I do this?

Thanks!

This is what the data looks like:

Data from CSV file

plotting – How do I flip one of my loops of current to be in the other direction?

I’m new to Mathematica and I have two loops of current that are both going in the same direction, but I want to flip them so that they go in opposite directions… I can’t figure out where I’m going wrong?

Clear("Global`*")
Q = 1;
(CapitalNu) = 100;
(Mu)o = 1;
R0 = 5;
r = {x, y, z};
r0 = {R0 Cos((2 (Pi))/(CapitalNu) i), 0, 
   R0 Sin((2 (Pi))/(CapitalNu) i)};
I0 = 1;
dl = {-((2 (Pi))/(CapitalNu)) Sin((2 (Pi))/(CapitalNu) i), 
   0, (2 (Pi))/(CapitalNu) Cos((2 (Pi))/(CapitalNu) i)};
rp = {xp(t), yp(t), zp(t)};
v = {xp'(t), yp'(t), zp'(t)};
(CapitalDigamma) = q v(Cross)(CapitalBeta)p;
m = 1;
q = 10;
{xp, yp, zp} = NDSolveValue(
  {m xp''(t) == (CapitalDigamma) ((1)), xp'(0) == .1, xp(0) == 2,
   m yp''(t) == (CapitalDigamma) ((2)), yp'(0) == 0, yp(0) == 3,
   m zp''(t) == (CapitalDigamma) ((3)), zp'(0) == 0, zp(0) == 0},
  {xp, yp, zp}, {t, 0, 200})

z = 0;
(CapitalBeta)1 = !(
*UnderoverscriptBox(((Sum)), (i = 0), ((CapitalNu) - 1)) (
*FractionBox((( )(((Mu)o)( )(I0)( ))), ((4)( 
)((Pi))( ))) {
*FractionBox((((dl(Cross)((r - r0))))((()(1)()))), 
SuperscriptBox((Norm(r - r0)), (3))), 
*FractionBox((((dl(Cross)((r - r0))))((()(2)()))), 
SuperscriptBox((Norm(r - r0)), (3)))}));
VectorPlot((CapitalBeta)1, {x, -10, 10}, {y, -10, 10}, 
 VectorPoints -> 24, StreamPoints -> Medium, 
 StreamColorFunction -> None)

This gives me if the currents are flowing the same way. I know that it works, but every time I mess with the VectorPlot it doesn’t look how it’s supposed to with the magnetic field lines of one of the two loops flowing in the opposite direction.

plotting – Solving non-linear equations self consistently

I am trying to solve two nonlinear equations self consistently and I have other fourth order algebraic equation. Such equations are important to calculate phase diagram in superconductors in co-existence region. I would like to have a plot of y and z for given x.

I am trying to make following plot.enter image description here

The blue curve in inset is z(M/Tco) versus x and blue curve in whole figure is y(T/Tco) versus x

My code are:

x = {0.057, 0.058, 0.0585, 0.06};
n = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20};
solvegn = NSolve(1/gn – Sqrt(1 + z^2/(Pi*(2n + 1)y + 4.4xPi*gn)^2) == 0, gn);

sceq1 = NSolve(2PiSum(((2n + 1)Pi(gn – 1))/(((2n + 1)Pi + 0.4Pi*(x/y))((2n + 1)Pi + 0.4Pix(gn/y))), {n, 0, 20}) – PolyGamma(0.5 + 0.2*(x/y)) + PolyGamma(0.5 + 0.2*(x/w)) – Log(y/1.02) == 0, {y});

sceq2 = NSolve(2PiSum(((2n + 1)Pi(gn – 1))/(((2n + 1)Pi + 4.4Pi*(x/y))((2n + 1)Pi + 4.4Pix(gn/y))), {n, 0, 20}) – PolyGamma(0.5 + 2.2*(x/y)) + PolyGamma(0.5) – Log(y/1.7) == 0, {z});

My approach is to solve first equation numerically which will give me four gn roots and I need to choose only real positive roots giving me in terms of y and z. For each n I need gn.

Then plugging gn in equation second and third gives me two nonlinear equations in terms of y and z and need to solve self consistently for y and z and sum here is Matsubara sum.

I used NSolve like above then FindRoot but didn’t work out.
NSolve::ratnz: NSolve was unable to solve the system with inexact coefficients. The answer was obtained by solving a corresponding exact system and numericizing the result.

I am wondering how to get y and z for different x and make a plot, any suggestions with the code would really be appreciable.

Thank you

plotting – Extracting intensity from density plot image given color bar

I have an image showing a density plot from a paper, as well as the corresponding color bar. I am trying to convert this back to a 2D array of intensities.

enter image description here

2

Here’s what I did, which works but seems to be imperfect.

imagedata = ImageData(plotimage)
colordata = ImageData(colorimage)((row))

where row is a number which selects a single row out of the center of the color bar. imagedata is a rank 2 array of {R,G,B} values, while colordata is a rank 1 array of {R,G,B} values (between 0 and 1). I assume the color bar goes from 2 to 7. I then sample a number of colors from the bar with equal spacings,

colorbar = colordata((1;;-1;;step))
for some integer step such as step = Round(Length@colordata/30.). Let ncols = Length@cols, the number of color sampels. This looks like

RGBColor@@#&/@colorbar
enter image description here

Since the image has a lot of white space which I want to differentiate, I add a single white element as the first element: colorbar = Prepend(colorbar,{1,1,1}).

Now my basic strategy is to get each pixel’s {R,G,B} (I downsample the image to make this process not take forever because it’s rather inefficient) and associate it to a single element of colorbar. I don’t know the best way to do this, but my strategy right now is to minimize Norm({R,G,B}-{R',G',B'}), to find the {R',G',B'} in colorbar which is “closest” by this metric to the color of the pixel, I don’t know if this is a good method of color matching though. I define a function

f(c_) := Module({n},
  n = First@First@Position(colordata,#)&@First@MinimalBy(colordata,Norm(c-#)&)-1;
  If(n==0,
     0,
     2. + 5 n/ncols
  )
  RGBColor @@ colordata((n))
)

which takes an {R,G,B} vector, uses MinimalBy to find the element of colorbar for which the Norm of the difference is minimal, and returns its index minus one. Since white was the first index, if the result it zero I return 0 while for non-white colors I scale the output between 2 and 5 like the original color scale.

Defining a color function from the sampled colors,

colorf(x_) := Blend(cols,(x-2)/5)

the plotted result looks like this:

ListDensityPlot(plotdataConverted,
ColorFunction -> colorf,
ColorFunctionScaling -> False,
InterpolationOrder -> 0,
PlotLegends -> Placed(BarLegend({colorf, {2, 7}}), Above),
PlotRange -> {2, 7},
ImageSize -> Small
)

enter image description here

This seems to work, but there are some subtle differences in the output. Overall it seems to me that the output is on average a bit lighter, and especially so near the edges. This is causing me some issues because I want the match to be as close as possible, and I cannot find a way to improve the accuracy of this method. Is there a simpler/more accurate way to do this? Bonus for efficiency.

plotting – How to plot two time intervals of a graph simultaneously?

The graphs of my provided code look approximately like the one in the picture below. How is it possible to plot such graphs? Please help how to break the axis scale as shown. Any suggestion appreciated. Thanks a lot.
enter image description here

Subscript(C, i)=2.5*10^6
Subscript(k, e)=315
σ=1*10^-9
Subscript(S, e)=1.58*10^-5
g=2.3*10^16
Subscript(C, e)=2.1*10^4
τ=1*10^-15
a=1/τ
Subscript(w, 1)=1
Subscript(s, 1)=y/(Subscript(w, 1)*σ)
Subscript(b, 1)=g/Subscript(C, e)*(1+(Subscript(k, e)*Subscript(s, 1)^2)/g)
Subscript(Δ, 1)=Sqrt(Subscript(b, 1)^2-4*Subscript(k, e)*Subscript(s, 1)^2*g/(Subscript(C, i)*Subscript(C, e)))
Subscript(p, 11)=(-Subscript(b, 1)+Subscript(Δ, 1))/2
Subscript(p, 12)=(-Subscript(b, 1)-Subscript(Δ, 1))/2
Subscript(T, i)=(Subscript(S, e)*g)/(2*π*τ*Subscript(C, i)*Subscript(C, e))*NIntegrate(BesselJ(0,y)*Exp(-((σ^2*Subscript(s, 1)^2)/4))*(Exp(-a*t)/((a+Subscript(p, 11))*(a+Subscript(p, 12)))+1/(Subscript(p, 11)-Subscript(p, 12))*(Exp(Subscript(p, 11)*t)/(Subscript(p, 11)+a)-Exp(Subscript(p, 12)*t)/(Subscript(p, 12)+a)))*y/(σ*Subscript(w, 1))^2,{y,0,100})
Subscript(T, e)=Subscript(T, i)+Subscript(S, e)/(2*π*τ*Subscript(C, e))*NIntegrate(BesselJ(0,y)*Exp(-((σ^2*Subscript(s, 1)^2)/4))*(-((a*Exp(-a*t))/((a+Subscript(p, 11))*(a+Subscript(p, 12))))+1/(Subscript(p, 11)-Subscript(p, 12))*((Subscript(p, 11)*Exp(Subscript(p, 11)*t))/(Subscript(p, 11)+a)-(Subscript(p, 12)*Exp(Subscript(p, 12)*t))/(Subscript(p, 12)+a)))*y/(σ*Subscript(w, 1))^2,{y,0,100})
Plot(Subscript(T, e),{t,0,1*10^-14})
Plot(Subscript(T, i),{t,0,1*10^-14})

plotting – How to plot two time intervals of a graph simultaneoulsy?

the graphs of my provided code look approximately like the picture below. How can I plot such gpaph, help me please. Any suggestion appreciated. Thanks a lot.
enter image description here

Subscript(C, i)=2.5*10^6
Subscript(k, e)=315
σ=1*10^-9
Subscript(S, e)=1.58*10^-5
g=2.3*10^16
Subscript(C, e)=2.1*10^4
τ=1*10^-15
a=1/τ
Subscript(w, 1)=1
Subscript(s, 1)=y/(Subscript(w, 1)*σ)
Subscript(b, 1)=g/Subscript(C, e)*(1+(Subscript(k, e)*Subscript(s, 1)^2)/g)
Subscript(Δ, 1)=Sqrt(Subscript(b, 1)^2-4*Subscript(k, e)*Subscript(s, 1)^2*g/(Subscript(C, i)*Subscript(C, e)))
Subscript(p, 11)=(-Subscript(b, 1)+Subscript(Δ, 1))/2
Subscript(p, 12)=(-Subscript(b, 1)-Subscript(Δ, 1))/2
Subscript(T, i)=(Subscript(S, e)*g)/(2*π*τ*Subscript(C, i)*Subscript(C, e))*NIntegrate(BesselJ(0,y)*Exp(-((σ^2*Subscript(s, 1)^2)/4))*(Exp(-a*t)/((a+Subscript(p, 11))*(a+Subscript(p, 12)))+1/(Subscript(p, 11)-Subscript(p, 12))*(Exp(Subscript(p, 11)*t)/(Subscript(p, 11)+a)-Exp(Subscript(p, 12)*t)/(Subscript(p, 12)+a)))*y/(σ*Subscript(w, 1))^2,{y,0,100})
Subscript(T, e)=Subscript(T, i)+Subscript(S, e)/(2*π*τ*Subscript(C, e))*NIntegrate(BesselJ(0,y)*Exp(-((σ^2*Subscript(s, 1)^2)/4))*(-((a*Exp(-a*t))/((a+Subscript(p, 11))*(a+Subscript(p, 12))))+1/(Subscript(p, 11)-Subscript(p, 12))*((Subscript(p, 11)*Exp(Subscript(p, 11)*t))/(Subscript(p, 11)+a)-(Subscript(p, 12)*Exp(Subscript(p, 12)*t))/(Subscript(p, 12)+a)))*y/(σ*Subscript(w, 1))^2,{y,0,100})
Plot(Subscript(T, e),{t,0,1*10^-14})
Plot(Subscript(T, i),{t,0,1*10^-14})