plotting – Using DateListPlot without connecting dots

I have a list of values like this:

enter image description here

When I plot this data using DateListPlot(data) I get a plot connecting the individual points such as:

enter image description here

My question are:

  1. How can I create the same plot but only getting the individual points without connect them by line?. Similar to the plot below:
  2. How can I get the AM or PM from the times and put them in the x-axis?
  3. How can I space the time to be every 5 minutes when plotting the data (similar to the picture below)?

EDIT:

The data is the following:

{{DateObject({2020, 7, 5, 8, 1, 0.}, "Instant", "Gregorian", -5.), 
  122.}, {DateObject({2020, 7, 5, 8, 6, 0.}, "Instant", 
   "Gregorian", -5.), 
  108.}, {DateObject({2020, 7, 5, 8, 11, 0.}, "Instant", 
   "Gregorian", -5.), 
  99.}, {DateObject({2020, 7, 5, 8, 16, 0.}, "Instant", 
   "Gregorian", -5.), 
  101.}, {DateObject({2020, 7, 5, 8, 21, 0.}, "Instant", 
   "Gregorian", -5.), 
  106.}, {DateObject({2020, 7, 5, 8, 26, 0.}, "Instant", 
   "Gregorian", -5.), 
  110.}, {DateObject({2020, 7, 5, 8, 31, 0.}, "Instant", 
   "Gregorian", -5.), 
  112.}, {DateObject({2020, 7, 5, 8, 36, 0.}, "Instant", 
   "Gregorian", -5.), 
  102.}, {DateObject({2020, 7, 5, 8, 41, 0.}, "Instant", 
   "Gregorian", -5.), 
  96.}, {DateObject({2020, 7, 5, 8, 46, 0.}, "Instant", 
   "Gregorian", -5.), 
  96.}, {DateObject({2020, 7, 5, 8, 51, 0.}, "Instant", 
   "Gregorian", -5.), 
  94.}, {DateObject({2020, 7, 5, 8, 56, 0.}, "Instant", 
   "Gregorian", -5.), 
  92.}, {DateObject({2020, 7, 5, 9, 1, 0.}, "Instant", 
   "Gregorian", -5.), 
  95.}, {DateObject({2020, 7, 5, 9, 6, 0.}, "Instant", 
   "Gregorian", -5.), 
  98.}, {DateObject({2020, 7, 5, 9, 11, 0.}, "Instant", 
   "Gregorian", -5.), 
  93.}, {DateObject({2020, 7, 5, 9, 16, 0.}, "Instant", 
   "Gregorian", -5.), 
  84.}, {DateObject({2020, 7, 5, 9, 21, 0.}, "Instant", 
   "Gregorian", -5.), 
  80.}, {DateObject({2020, 7, 5, 9, 26, 0.}, "Instant", 
   "Gregorian", -5.), 
  78.}, {DateObject({2020, 7, 5, 9, 31, 0.}, "Instant", 
   "Gregorian", -5.), 
  74.}, {DateObject({2020, 7, 5, 9, 36, 0.}, "Instant", 
   "Gregorian", -5.), 
  60.}, {DateObject({2020, 7, 5, 9, 41, 0.}, "Instant", 
   "Gregorian", -5.), 
  54.}, {DateObject({2020, 7, 5, 9, 46, 0.}, "Instant", 
   "Gregorian", -5.), 
  57.}, {DateObject({2020, 7, 5, 9, 51, 0.}, "Instant", 
   "Gregorian", -5.), 
  59.}, {DateObject({2020, 7, 5, 9, 56, 0.}, "Instant", 
   "Gregorian", -5.), 68.}}

plotting – How do I create a piecewise function using Do[] or While[]?

The following non-linear circuit is an uncontrolled three-phase full-wave 6-pulse rectifier. The inputs are $v_{an}(t) = V_m sin (omega t)$, $v_{bn}(t) = V_m sin (omega t-120°)$ and $v_{cn}(t) = V_m sin (omega t+120°)$. $R$ and $L$ are the load’s resistance and inductance, $omega$ and $T$ are voltage sources’ angular frequency and period, and $V_m$ are the sources’ amplitude; the diodes are modeled as ideals. The unknown to solve for is $i(t)$, the load’s current (not shown in the diagram). The circuit’s differential equation is

$i'(t) + dfrac{R}{L} i(t) = dfrac{sqrt{3} V_m}{L} sin{(omega t + theta)} tag*{}$

subject to the initial condition

$i(t_0) = I_0 tag*{}$

Uncontrolled three-phase full-wave 6-pulse rectifier

I consider it unnecessary to explain the functioning of the circuit, and don’t want to confuse you with circuit theory. Basically, due to the non-linearity, there’s not a single expression that describes the solution of the circuit for all $ t ge 0 $. However, we can obtain a piecewise solution: for each cycle or period $T$, we express $i(t)$ in seven segments/pieces. Each piece has the same general form, which is:

$i(t) = dfrac{sqrt{3} V_m omega L}{R^2 + (omega L)^2} (- cos{(omega t + theta)} + e^{frac{R}{L}(t_0-t)} cos{(omega t_0 + theta)}) + dfrac{sqrt{3} V_m R}{R^2 + (omega L)^2} (sin{(omega t + theta)} – e^{frac{R}{L}(t_0-t)} sin{(omega t_0 + theta)}) + I_0 e^{frac{R}{L}(t_0-t)} tag*{}$

I developed the following algorithm that does what I need:

Given the circuit’s parameters R, L, w, T = 2 Pi/w,
Vm, the initial condition IC, and n (where n is a natural number used to end the loop). In the following, whenever I say “expr“, sustitute it with (Sqrt(3) Vm w L)/(R^2 + (w L)^2) (- Cos(w t + θ) + E^(R/L (t0 - t)) Cos(w t0 + θ)) + (Sqrt(3) Vm R)/(R^2 + (w L)^2) (Sin(w t + θ) - E^(R/L (t0 - t)) Sin(w t0 + θ)) + I0 E^(R/L (t0 - t))

  1. Set k = 0.
  2. For k T < t ≤ k T + T/12:
    1. Set θ = 90 Degree. If k == 0, set t0 = 0. If k ≥ 1, set t0 = k T.
    2. If k == 0, set I0 = IC. If k ≥ 1, set I0 = i(t0).
    3. Add/append expr (using the new values of t0, I0 and θ) as a new piece of i(t) for the interval k T < t ≤ k T + T/12.
  3. For k T + T/12 < t ≤ k T + T/4:
    1. Set t0 = k T + T/12 and θ = 30 Degree.
    2. Set I0 = i(t0).
    3. Add expr (using the new values of t0, I0 and θ) as a new piece of i(t) for the interval k T + T/12 < t ≤ k T + T/4.
  4. For k T + T/4 < t ≤ k T + 5 T/12:
    1. Set t0 = k T + T/4 and θ = -30 Degree.
    2. Set I0 = i(t0).
    3. Add expr (using the new values of t0, I0 and θ) as a new piece of i(t) for the interval k T + T/4 < t ≤ k T + 5 T/12.
  5. For k T + 5 T/12 < t ≤ k T + 7 T/12:
    1. Set t0 = k T + 5 T/12 and θ = -90 Degree.
    2. Set I0 = i(t0).
    3. Add expr (using the new values of t0, I0 and θ) as a new piece of i(t) for the interval k T + 5 T/12 < t ≤ k T + 7 T/12.
  6. For k T + 7 T/12 < t ≤ k T + 3 T/4:
    1. Set t0 = k T + 7 T/12 and θ = -150 Degree.
    2. Set I0 = i(t0).
    3. Add expr (using the new values of t0, I0 and θ) as a new piece of i(t) for the interval k T + 7 T/12 < t ≤ k T + 3 T/4.
  7. For k T + 3 T/4 < t ≤ k T + 11 T/12:
    1. Set t0 = k T + 3 T/4 and θ = 150 Degree.
    2. Set I0 = i(t0).
    3. Add expr (using the new values of t0, I0 and θ) as a new piece of i(t) for the interval k T + 3 T/4 < t ≤ k T + 11 T/12.
  8. For k T + 11 T/12 < t ≤ k T + T:
    1. Set t0 = k T + 11 T/12 and θ = 90 Degree.
    2. Set I0 = i(t0).
    3. Add expr (using the new values of t0, I0 and θ) as a new piece of i(t) for the interval k T + 11 T/12 < t ≤ k T + T.
  9. Increase k by one, that is, evaluate k++ or set k = k + 1.
  10. If k < n, return to step 2 and repeat. If k == n, stop the loop/algorithm.

So, I want to implement the previous algorithm in Mathematica, in order to define i(t) as a piecewise function and plot it, where I can assign the values of R, L, w, T = 2 Pi/w, Vm, IC and n before plotting. Obviously the Piecewise() function will be needed, and perhaps Do() or While(), and Module() might be helpful, but I don’t know how to use them to define a piecewise function.

I hope you understand what I’m trying to do, otherwise please ask in the comments.

plotting – Why isn’t LogLinearPlot showing output?

I’m trying to make a log-x plot of a function evaluated over a specified range. The function is an interpolation function defined (by the range of data provided) between 1e5 and 1e9.
But when I try to plot the function over this range using LogLinearPlot, i get a series of errors about evaluations waaay outside of this range, and then no plot is shown.

In the interest of providing a fully working example, here is my function to plot – it simply accepts some points and provides a linear interpolation between them (probably an overly complicated way to do it)

fluxPoints = {s0, s1, s2, s3, s4};
fluxBinCenters = {1*10^5, 1*10^6, 1*10^7, 1*10^8, 1*10^9};
fluxSpectrumPoints = Transpose({fluxBinCenters, fluxPoints});
sourceFluxSpectrum = Interpolation(fluxSpectrumPoints, InterpolationOrder -> 1);
sourceSpectrum(E_, fluxpars_) := sourceFluxSpectrum(E) /. {s0 -> fluxpars((0)), s1 -> fluxpars((1)), s2 -> fluxpars((2)), s3 -> fluxpars((3)), s4 -> fluxpars((4))};

The following code explicitly specifies the x-points to evaluate, calculates the corresponding y-values, and plots them on the log-x axis as desired:

somefluxpars = {10*10^-8, 100*10^-8, 300*10^-8, 250*10^-8, 100*10^-8};
evalpoints = 10^Range(6, 9, 1);
evalfluxes = Table(sourceSpectrum(energy, somefluxpars), {energy, evalpoints});
spectrumPlot = Transpose({evalpoints, evalfluxes});
ListLogLinearPlot(spectrumPlot, PlotRange->All, Joined->True, Mesh->All)

This produces the plot:

Correct plot with expected values spanning the range 1e6 to 1e9

I would like to make this plot, but without having to manually specify the plot points.
However, when I try the following:

LogLinearPlot(sourceSpectrum(energy, somefluxpars), {energy, 1*10^6, 1*10^9}, {PlotRange -> {All, {1*10^6, 1*10^9}}, PlotPoints -> 4, Mesh -> Full})

I get a bunch of errors indicating that Mathematica tried to evaluate sourceSpectrum at x-values of 13, 16, 18… (well outside the requested plot range?!) and no curve is shown.

Empty plot axes and errors

I’ve tried various alterations on PlotRange->{1*10^6,1*10^9}, PlotRange->All, or dropping it entirely, but it has no effect.

If I use Plot instead of LogLinearPlot, then the data shows up as expected (but, of course, without the desired log x-scale).

plotting – why 3d plot‘s ticks in x,y,z has different directions

Plot3D[0, {x, -2, 2}, {y, -2, 2}, Boxed -> {Left, Bottom, Back},BoxRatios -> {1, 1, 0.7},TicksStyle -> Black, AxesEdge -> {{-1, -1}, {1, -1}, {-1, -1}}, ViewPoint -> 10 {1.5, -1.5, 1}]

It’s output is
enter image description here

Why the ticks on the x-axis are upright, and the y-axis and z-axis are all attached to the plane. How can I make the x axis lie flat. I looked at all the options through AbsoluteOptions, but it does not seem to find any one option to control it.

plotting – ContourPlot for a certain value

Consider this example:

f[x_] := -I*2*x + 3*x^2

which is a complex function defined on a complex plane $x=x_r+ix_i$

It is convenient to plot the contour of its real part Re[f] with

ListContourPlot[Re[Table[ComplexExpand[f[xr + I*xi]], {xr, 0, 0.2, 0.01}, {xi, -0.05,
 0.05, 0.001}]]]

But sometimes we want to only show the contour for a certain value with a legend for the specific value. For example, how can I only plot the contour for Re[f]=0 with a legend for it?

I naively tried as follows, but it didn’t work.

ListContourPlot[Re[Table[ComplexExpand[f[xr + I*xi]], {xr, 0, 0.2, 0.01}, {xi, -0.05,
  0.05, 0.001}]] == 0]

Thank you for any help.

plotting – Graph of Laplace equation

I have solved the following Laplace equation

a0 = (1/Pi) Integrate(Cos(φ)^2 + Sin(φ)^3, {φ, 0, 2 Pi})
an = (1/Pi) Integrate((Cos(φ)^2 + Sin(φ)^3)*Cos(n*φ), {φ, 0, 2 Pi})
Plot(an, {n, 0, 10})
bn = (1/Pi) Integrate((Cos(φ)^2 + Sin(φ)^3)*Sin(n*φ), {φ, 0, 2 Pi})
ann = an*Cos(n*φ)
bnn = bn*Sin(n*φ)
a = Sum(((r/4)^n)*(ann + bnn), {n, 1, Infinity})
f(r_, φ_) := a0/2 + a
ParametricPlot3D({r,φ, f(r, φ)}, {r, 0, 1}, {φ, 0, 2 Pi})
Plot3D(f(r, φ), {r, 0, 1}, {φ, 0, 2 Pi})

My problem is that Plot3D and ParametricPlot3D doesn’t work. Any help?

Plotting Data using gnuplot through bash

I am running this program SCRIPT.sh,

#!/bin/bash 
FFT_FILE="$(find . -type f -iname "HR*.fft")" 
FFT_FILE1=$FFT_FILE".GNUPLOT" 
od -f -v -w8 $FFT_FILE > $FFT_FILE1 
gnuplot -persist <<-EOFMarker 
    reset 
    set term postscript enh 
    set out 'FFT_1.ps' 
    set xlabel 'Frequency (Hz)' 
    set key box 
    filename="$FFT_FILE1" 
     stats filename nooutput 
     max_row = STATS_records 
     plot ((1000.0/4880.0):(1000.0/59.0)) filename u ($0/(max_row*81.92e-6)):(sqrt(($2*$2)+($3*$3))) w l lw 3 title "FFT" 
    reset 
EOFMarker

but the output comes as

gnuplot>plot ((1000.0:4880.0):(1000.0/59.0)) filename u (./SCRIPT.sh/(max_row*81.92e-6)):(sqrt((*)+(*))) w l lw 3 title "FFT"
line 0: invalid expression

May I request for detailed explanation and help regarding this situation?

Optimization for plotting

I would like to know if there is any way to improve the speed of the following program:

f := 1 - (2 M)/r; M = 1;

Va := f ((l (l + 1))/r^2 + ((1 - S^2) !(
*SubscriptBox(((PartialD)), (r))f))/r);(*Axial potential*)

rmin := r /. Last(FindMaximum({V, r > M}, r))

V1 := f !(
*SubscriptBox(((PartialD)), (r))V);
V2 := f !(
*SubscriptBox(((PartialD)), (r))V1);
V3 := f !(
*SubscriptBox(((PartialD)), (r))V2);
V4 := f !(
*SubscriptBox(((PartialD)), (r))V3);
V5 := f !(
*SubscriptBox(((PartialD)), (r))V4);
V6 := f !(
*SubscriptBox(((PartialD)), (r))V5);

(CapitalGamma) := 
  1/Sqrt(-2 V2) (1/8 (V4/V2) (1/4 + (n + 1/2)^2) - 
     1/288 (V3/V2)^2 (7 + 60 (n + 1/2)^2));
(CapitalOmega) := 
  1/(-2 V2) (5/6912 (V3 /V2)^4 (77 + 188 (n + 1/2)^2) - 
     1/384 (((V3)^2  V4)/(V2)^3) (51 + 100 (n + 1/2)^2) + 
     1/2304 (V4/V2)^2 (67 + 68 (n + 1/2)^2) + 
     1/288 ((V3 V5)/(V2)^2) (19 + 28 (n + 1/2)^2) - 
     1/288 (V6/V2) (5 + 4 (n + 1/2)^2));

(Omega) := Sqrt(
  V + (CapitalGamma) Sqrt((-2 V2)) - 
   I (n + 1/2) (1 + (CapitalOmega)) Sqrt((-2 V2)));

(**********Plots**********)
V := Va;
S = 0;
Print(Style("Scalar perturbation", {Bold, Larger}), " Spin = ", S)

pp = 100;

l = 2; n = 0;
P1 = Plot({Re((Omega)) /. r -> rmin, -Im((Omega)) /. 
      r -> rmin }, {M, 10^-3, 30}, AxesLabel -> {"M", "(Omega)"}, 
    PlotStyle -> {{Line, Blue}, {Dashed, Blue}}, 
    PlotLegends -> Placed({"(ScriptL)=2"}, {0.7, 0.8}), 
    PlotRange -> {{0, 30}, {0, Automatic}}, MaxRecursion -> Infinity, 
    PlotPoints -> pp); // AbsoluteTiming
l = 3; n = 0;
P2 = Plot({Re((Omega)) /. r -> rmin, -Im((Omega)) /. 
      r -> rmin }, {M, 10^-3, 30}, AxesLabel -> {"M", "(Omega)"}, 
    PlotStyle -> {{Line, Red}, {Dashed, Red}}, 
    PlotLegends -> Placed({"(ScriptL)=3"}, {0.7, 0.8}), 
    PlotRange -> {{0, 30}, {0, Automatic}}, MaxRecursion -> Infinity, 
    PlotPoints -> pp); // AbsoluteTiming
l = 4; n = 0;
P3 = Plot({Re((Omega)) /. r -> rmin, -Im((Omega)) /. 
      r -> rmin }, {M, 10^-3, 30}, AxesLabel -> {"M", "(Omega)"}, 
    PlotStyle -> {{Line, Black}, {Dashed, Black}}, 
    PlotLegends -> Placed({"(ScriptL)=4"}, {0.7, 0.8}), 
    PlotRange -> {{0, 30}, {0, Automatic}}, MaxRecursion -> Infinity, 
    PlotPoints -> pp); // AbsoluteTiming

Show(P1, P2, P3, Frame -> True, FrameLabel -> {"Mass", "Frequency"}, 
 ImageSize -> Medium)

I have to make several analysis for even more complicated Vs, and several different plots. They are taking longer and longer and I have no idea how make this faster. Right now it is taking several minutes to run it.

plotting – Correcting the Color Scale of a MatrixPlot

I did a MatrixPlot of a set of values that range between 0 and 1. I got the following first plot with no problems:
enter image description here

As we can see from the legend, the values range between 0 and 1. Now, I am doing another MatrixPlot with a set of smaller values that range between 0.01 and 0.22. I got this plot:

enter image description here

I want the second plot to use the same scale used by the first plot (between 0 and 1) and hence the same color scale so we can compare the two plots with each other. How can I tell Mathematica to use the same scale of the first plot for second plot?

data – Problem plotting a bifurcation diagram of logistic map

I see related information from here.

interval = 0.001;
results = 
  Reverse(Transpose(
    Table(logisticValues = 
      Table(Nest(a # (1 - #) &, RandomReal(), 2000), {1000});
     intervals = Table(i, {i, 0, 1 - interval, interval});
     result = BinCounts(logisticValues, {0, 1, interval})/1000;
     Log(result + 0.001), {a, 2.9, 4, 0.001})));
gradraft = 
 ArrayPlot(70 + 10 results, FrameLabel -> {"x(T)", "μ"}, 
  FrameTicks -> {Table({i, N((i - 1)/(Length(results) - 1))}, {i, 
      0.1*(Length(results) - 1) + 1, 
      0.9 (Length(results) - 1) + 1, (Length(results) - 1)/4}), 
    Table({i, 
      N(2.9 + (i - 1)*(4 - 2.9)/(Length(results((1))) - 1), 
       1)}, {i, (3 - 2.9) (Length(results((1))) - 1)/(4 - 2.9) + 1, 
      Length(results((1))), (Length(results((1))) - 1)/5})})

enter image description here

The following code is from the help information of Nest function:

ListPlot(Table(
   Thread({r, Nest(r # (1 - #) &, Range(0, 1, 0.01), 1000)}), {r, 0, 
    4, 0.01}) // Transpose)