ggplot super slow for plotting sf objects in RStudio on macOS Mojave

I'm running the following command in RStudio on a Mac:

texas <- tracts(state='TX', class="sf")

tic()
ggplot(texas) + geom_sf()
toc()

tic()
plot(texas %>% st_geometry)
toc()

The execution of ggplot took 134 seconds, while the execution of plot () took 2.6 seconds. My colleague has run the same code on his PC, ggplot was much faster at 10 seconds.

Does anyone know why ggplot is so slow to print simple functions on a Mac?

Plotting – How to manually select the dot plot with ListPlot from a large dataset that is not consistent?

I have a list of the form

    data={{0.5, 3.14026}, {0.525, 3.13121}, {0.55, 3.1222}, {0.575, 
  3.11323}, {0.6, 3.10429}, {0.625, 3.0954}, {0.65, 3.08654}, {0.675, 
  3.07772}, {0.7, 3.06894}, {0.725, 3.0602}, {0.75, 3.0515}, {0.775, 
  3.04284}, {0.8, 3.03421}, {0.825, 3.02563}, {0.85, 3.01708}, {0.875,
   3.00857}, {0.9, 3.0001}, {0.925, 2.99168}, {0.95, 2.98329}, {0.975,
   2.97493}, {1., 2.96662}, {1.025, 2.95835}, {1.05, 2.95011}, {1.075,
   2.94192}, {1.1, 2.93376}, {1.125, 2.92565}, {1.15, 
  2.91757}, {1.175, 2.90953}, {1.2, 2.90153}, {1.225, 2.89357}, {1.25,
   2.88565}, {1.275, 2.87777}, {1.3, 2.86993}, {1.325, 
  2.86212}, {1.35, 2.85436}, {1.375, 2.84663}, {1.4, 2.83895}, {1.425,
   2.8313}, {1.45, 2.82369}, {1.475, 2.81612}, {1.5, 2.80859}, {1.55, 
  2.79365}, {1.6, 2.77888}, {1.65, 2.76426}, {1.7, 2.7498}, {1.75, 
  2.7355}, {1.8, 2.72135}, {1.85, 2.70736}, {1.9, 2.69351}, {1.95, 
  2.67981}, {2., 2.66626}, {2.05, 2.65284}, {2.1, 2.63957}, {2.15, 
  2.62644}, {2.2, 2.61345}, {2.25, 2.60059}, {2.3, 2.58787}, {2.35, 
  2.57528}, {2.4, 2.56282}, {2.45, 2.55048}, {2.5, 2.53828}, {2.55, 
  2.5262}, {2.6, 2.51424}, {2.65, 2.5024}, {2.7, 2.49069}, {2.75, 
  2.47909}, {2.8, 2.46761}, {2.85, 2.45624}, {2.9, 2.44499}, {2.95, 
  2.43385}, {3., 2.42282}, {3.125, 2.39573}, {3.25, 2.3693}, {3.375, 
  2.34351}, {3.5, 2.31835}, {3.625, 2.29378}, {3.75, 2.2698}, {3.875, 
  2.24639}, {4., 2.22352}, {4.125, 2.20119}, {4.25, 2.17938}, {4.375, 
  2.15806}, {4.5, 2.13723}, {4.625, 2.11688}, {4.75, 2.09698}, {4.875,
   2.07753}, {5., 2.05851}, {5.125, 2.03991}, {5.25, 2.02172}, {5.375,
   2.00393}, {5.5, 1.98652}, {5.625, 1.96949}, {5.75, 
  1.95282}, {5.875, 1.93651}, {6., 1.92054}, {6.125, 1.90491}, {6.25, 
  1.88961}, {6.375, 1.87462}, {6.5, 1.85995}, {6.625, 1.84557}, {6.75,
   1.8315}, {6.875, 1.8177}, {7., 1.80419}, {7.125, 1.79095}, {7.25, 
  1.77798}, {7.375, 1.76526}, {7.5, 1.7528}, {7.625, 1.74058}, {7.75, 
  1.7286}, {7.875, 1.71685}, {8., 1.70534}, {8.125, 1.69404}, {8.25, 
  1.68296}, {8.375, 1.6721}, {8.5, 1.66144}, {8.625, 1.65099}, {8.75, 
  1.64073}, {8.875, 1.63066}, {9., 1.62078}, {9.125, 1.61109}, {9.25, 
  1.60157}, {9.375, 1.59223}, {9.5, 1.58307}, {9.625, 1.57407}, {9.75,
   1.56523}, {9.875, 1.55655}, {10., 1.54803}, {11., 1.48512}, {12., 
  1.43045}, {13., 1.38275}, {14., 1.34098}, {15., 1.30427}, {16., 
  1.27192}, {17., 1.24334}, {18., 1.21802}, {19., 1.19554}, {20., 
  1.17555}, {21., 1.15774}, {22., 1.14185}, {23., 1.12764}, {24., 
  1.11493}, {25., 1.10355}, {26., 1.09334}, {27., 1.08417}, {28., 
  1.07594}, {29., 1.06853}, {30., 1.06187}, {32., 1.05048}, {34., 
  1.04122}, {36., 1.03369}, {38., 1.02755}, {40., 1.02254}, {42., 
  1.01845}, {44., 1.01511}, {46., 1.01238}, {48., 1.01014}, {50., 
  1.00831}, {55., 1.00506}, {60., 1.00308}, {65., 1.00188}, {70., 
  1.00115}, {75., 1.0007}, {80., 1.00043}, {85., 1.00027}, {90., 
  1.00018}, {95., 1.00013}, {100., 1.00012}}

I want to draw my data in the interval 0 to 60. So I use

ListPlot[data, PlotRange -> {{0, 60}, {0, 4}}]

However, since I have many points in the interval 0-10, the points of ListPlot agglutinate at such an interval. How can I overcome such agglutination without manually deleting some points? Is there a way to choose which points to plot and which to exclude? Suppose I want the points to be separated by a distance of 2 or 3, or whichever I think best.
Thank you in advance.

Plotting – DensityPlot: error messages and strange bar legend

I want to draw the following DensityPlot given by axes Trr and n:

Mpl = 2.4*10^18;
mpsi = 1000;
Lambda = 10^15;
xR = 10^-5;
DensityPlot(135*Sqrt(10)/(8*Pi^8*106.75^(3/2))*Mpl*mpsi/Lambda^2(mpsi/Trr)^(-n/2)*NIntegrate((BesselK(2, x)^2 - BesselK(1, x)^2)*x^(2 + n/2), {x, xR, 1000}), {Trr, 10^-3, 10^3}, {n, 1, 4}, ScalingFunctions -> {"Log10", Automatic, "Log10"}, PlotLegends -> Placed(BarLegend(Automatic), {After, Top}), Ticks -> {ScientificForm(#), Automatic, Automatic}, FrameLabel -> {"!(*SubscriptBox((T), (r))) (GeV)", "n"}, PlotPoints -> 100, MaxRecursion -> 1, AspectRatio -> 1/1.4, PlotRangePadding -> None)

Mathematica gives me the correct graph, but the legend bar is displayed with this weird red error count and no check marks or labels.

Enter image description here

The error messages I receive are

The coordinate {indeterminate, indefinite} should be a pair of numbers or a scaled or offset form.

The coordinate {{indefinite, indefinite}, offset ({4., 0}, {indefinite, indefinite})} should be a pair of numbers or a scaled or offset form.

The coordinate {{indefinite, indefinite}, offset ({2,5, 0}, {indefinite, indefinite})} should be a pair of numbers or a scaled or offset form.

Thank you for your help!

Plotting – How do I plot a plane AND a diagram in a 3D plot?

I want to draw the van der Waals equations, especially the part that shows the van der Waals loop. At first I tried to plot it with that Plot3D() Function, so that the upper edges are very uneven and even MaxRecursion set to 15 I could not get rid of the problem.

R=8.314;
a=363.7*10^-3;
b=42.7*10^-6;
Plot3D(p, {V, 0, 0.001}, {T, 290, 320}, PlotTheme -> "Scientific", 
 PlotRange -> {0, 12000000}, AxesLabel -> {"V", "T", "p"}, 
 ImageSize -> 1100, Exclusions -> {V == 0, T == 0}, MaxRecursion -> 8,
  ViewPoint -> {0, -(Infinity), 0}, ColorFunction -> Green)

When I used that ContourPlot3D()I did not have this problem.

ContourPlot3D((R T)/(V - b) - a/V^2 == p, {V, 0, 0.001}, {T, 280, 
  340}, {p, 0, 12000000}, AxesLabel -> {"V", "T", "p"}, 
 ImageSize -> Large, AspectRatio -> 0.8)

Now I want to have a graph that has a certain value for T (such graphs are called isotherms) plotted on the same graph ContourPlot3D, Also, I want to create a slider in which I specify the value for T.
I know that Show() Function can be used but does not know how to use it in this scenario because I want to draw two different things (a layer and a diagram) in a 3D diagram.

Is there a way there? If so, I would be very grateful for your help ๐Ÿ™‚

Plotting – To change plot marks in ListPolarPlot

I tried to draw with the one polar curve ListPolarPlot Function with custom markers. However, when I use PlotMarkers There are several errors (see attached screenshot). I have used successfully in the past PlotMarkers With ListPlotthat seems to be the problem ListPolarPlot,

Screenshot with errors when using PlotMarkers

So far, I could only change the color and size of the points PlotStylebut can not find a way to change their shape:

Data = {{0, 70}, {ฯ€/12, 45}, {ฯ€/6, 60}, {ฯ€/4, 90}, {ฯ€/2, 30}}

ListPolarPlot(Data, PolarAxes -> True, PolarGridLines -> Automatic, 
  Joined -> False, PolarTicks -> {"Degrees", Automatic}, 
  BaseStyle -> {FontWeight -> Bold, FontSize -> 12}, 
  PlotStyle -> {Blue, PointSize -> 0.014})

Enter image description here

Plotting – A question about 3D plotting

I have an equation:

$ x (z ln z) = y $,

For different values โ€‹โ€‹of $ x $ and $ y $ we can solve this equation for z, for example $ x = 3 $ and $ y = 1 $, we have:

FindRoot(3 z Log(z) == 1, {z, 0.1, 5})

I like to have a 3D rendering where $ x $ varies, for example, from $ 1 $ to $ 3 $, and $ y $ from $ 2 $ to $ 4 $and the third dimension, to be the solutions of the equation, that is, $ z $, How can I implement this in Mathematica?

Plotting – Contour Plotting does not take any previously defined expressions?

I'm new to Mathematica, so maybe my question sounds silly, but I hope you help me.

While learning ContourPlot, I learned that it does not work if I use the previously defined expressions as inputs, and it seems they are just typed in manually

For example

f1 = x^2/9 + y^2/4 == 1
f2 = x^2 - 1 == y

then

ContourPlot[{f1, f2}, {x, -3, 3}, {y, -3, 8}] 

leads to nothing, while the expressions are written manually in z

ContourPlot[{x^2/9 + y^2/4 == 1, x^2 - 1 == y}, {x, -3, 3}, {y, -3, 8}]

gives what I want …

What's more, this also seems to happen when using NSolve … Can anyone tell me what's going on?

Thank you in advance:]

Plot3D: Plot a piecewise function with different colors when plotting multiple functions

func1 = -(n1^2 + n2^2) + 100

plt2 = Plot3D(Piecewise({{cb1((1)) + 100,n1 <= 5 && n2 <= 5}}, cb2((1))) + 75,
  {n1, 0, 10}, {n2, 0, 10}, 
  MeshFunctions -> {#3 &}, 
  Mesh -> {{100}}, 
  MeshShading -> {Opacity(.6, Red), Opacity(.6, Green)}, 
  ExclusionsStyle -> Opacity(.6, Blue),
  BoundaryStyle -> None);

Show(Plot3D(func1, {n1, 0, 10}, {n2, 0, 10}, AxesLabel -> Automatic), plt2)

Enter image description here

Alternatively, construct two functions from your own Piecewise Function:

pw = PiecewiseExpand(Piecewise({{cb1((1)) + 100, n1 <= 5 && n2 <= 5}}, 
  cb2((1))) +  75);
{pw1, pw2} = {ConditionalExpression @@ pw((1, 1)), 
   ConditionalExpression(pw((2)), Not@pw((1, 1, 2)))};

Plot3D({func1,  pw1, pw2}, {n1, 0, 10}, {n2, 0, 10}, 
   AxesLabel -> Automatic, 
  PlotStyle -> {ColorData(97)(1), Opacity(.5, Red), Opacity(.5, Green)})

Enter image description here

Plotting – given many points, how to transform them into an arc that seems to be antenna?

I hope I can get some advice. I want to create a bow that looks like it's seen from above. as if you are sitting in an airplane and looking at the bow from above.

From these questions, I was able to create a 2D sheet. From this function on this question, I can even generate 100 points or more, which we then use to construct an arc. but if the bow looks like this:

Enter image description here

but I want the bow to be seen the way you look at it from above. something like that, but I really want a bird's-eye view from above:

Enter image description here

Is there a kind of equation that allows me to transform any point to make it look like I'm looking up?

Also remember that my coordinate system looks like this:

Enter image description here