Alan Bromborsky - 2024-06-07

I solved it with these commands to label the end points of the log axis -

   real y= point(S).y;

    string Xmin = "$"+format("%.0e",true,xmin)+"$";
    string Xmax = "$"+format("%.0e",true,xmax)+"$";

    xtick(spk_data,shift(0,-5pt)*Label(Xmin),(xmin,y));
    xtick(spk_data,shift(0,-5pt)*Label(Xmax),(xmax,y));

I am plotting a semi-log plot. The xaxis goes from 20 to 20000. I am using the following code for plotting:

  void plot()
  {
    picture spk_data;
    size(spk_data,800,400,IgnoreAspect);
    scale(spk_data,Log,Linear);

    xlimits(spk_data,20.0,20000.0);
    ylimits(spk_data,0,100);

    draw(spk_data,graph(spk_data,col_data[0].data,col_data[1].data),black);

    yaxis(spk_data,latex_names[1], LeftRight(), RightTicks(pTick=.8red, ptick=grey, extend=true));
    xaxis(spk_data,latex_names[0], BottomTop(), Ticks(Label("$%.2f$",black),beginlabel=true, endlabel=true, pTick=.8red, ptick=grey, extend=true));

    shipout("plot_test",spk_data);
  }

I have attached the output (pdf) of the code. How can I get the beginning (20) and the end (20000) of the x-axis labeled in a appropriate format. Thank you for any help you can give. I proselytize your code every chance I get.

 

Last edit: Alan Bromborsky 2024-06-08