1
$\begingroup$

i trying to adjust the "resolution" of the axes of my plots, that is to say, i wants modify the values of y-axis so that I represent the values with two decimals after the point. This are myy two codes:

Plot[solucion[t], {t, 0, 80}, PlotRange -> {0, .55}] ("left image")

or

Plot[solucion[t], {t, 0, 80}, PlotRange -> Full] ("Right image")

The output is the following two images.

enter image description here

The left image correspond to first code "PlotRange -> {0, .55}" but i want that intervals to show as the image of right from origin (0.00,0.05,0.10,...) but using "PlotRange -> Full" the x-axis moves above the origin and i want it not to move from the origin.

My explicit question is how to properly use PlotRange or any other instrcution inside Plot for to adjust the values of my plot??

Is it possible? Could you please help me?

Any suggestions are very appreciated

My complete code is:

H[s_, \[Sigma]_] := 
Which[s <= 0, 1, s > \[Sigma], 0, True, 1 - s/\[Sigma]]
(*Subscript[H, \[Sigma]](s) es una step function modificada que \
determina el I/O de crecimiento/muerte celular en base a la \  
compresion donde "s = (\[Psi]-Subscript[\[Psi], 0]) con Subscript[\
\[Psi], 0]=Subscript[\[Phi], n]+Subscript[\[Phi], t]+m*)
\[CapitalSigma][Y_, 
psi0_] := ((Y - psi0)/(1 - Y))*((2 - psi0)/(
1 - psi0)) (*Sigma es una función que mide el estres celular donde \
"Y" es del modulo de Young*)
solucion[t_] = With[
{gaman = 0.746,  (*reproduccion celulas sanas*)
gamat = 0.97,    (*reproducion celulas tumorales*)
psi0 = 0.75,      (*razon de volumen libre de estres*)
psin = 0.6,        (*valor umbral que detiene el crecimiento c. 
sanas*)
psit = 0.8,        (*valor umbral que detiene el crecimiento c. 
tumolaes*)
deltat = 0.03,  (*rapidez muerte celulas tumorales*)
deltan = 0.1,    (*rapidez muerte celulas sanas*)
mun = 0.1,           (*rapidez reproduccion MEC por celulas sanas*)


mut = 
 0.002,        (*rapidez reproduccion MEC por celulas tumorales*)


nu = 0.000016, (*coeficiente de degradacion de la MEC por enzimas*)


pin = 6000000,(*produccion de enzimas que degradan la MEC por c. 
sanas*)
pit = 3000000,(*produccion de enzimas que degradan la MEC por c. 
tumorales*)
tau = 0.005,          (*tiempo de vida medio de las enzimas*)
fo = 0.25,          (*suministro de oxigeno*)
fg = 0.16,          (*suministro de glucosa*)
betan = 
 1.2,      (*tasa de absorcion de nutrientes celulas \
sanas*)(*variable*)
betat = 
 1.3,      (*tasa de absorcion de nutrientes celulas \
tumorales*)(*variable*)
\[Sigma] = 
 0.2},            (*parametro de transciion de Subscript[
H, \[Sigma]](s)=1 y Subscript[H, \[Sigma]](s)=0*)
NDSolve[{
 fin'[t] == 
  oxi[t]*gaman*fin[t]*
    H[(fin[t] + fit[t] + mat[t]) - psin, \[Sigma]] - (1 - oxi[t])*
    deltan*fin[t],
 fit'[t] == 
  glu[t]*gamat*fit[t]*
    H[(fin[t] + fit[t] + mat[t]) - psit, \[Sigma]] - (1 - glu[t])*
    deltat*fit[t],
 mat'[t] == 
  mun*fin[t]*\[CapitalSigma][fin[t] + fit[t] + mat[t], psi0] + 
   mut*fit[t]*\[CapitalSigma][fin[t] + fit[t] + mat[t], psi0] - 
   nu*enz[t]*mat[t],
 enz'[t] == 
  pin*fin[t]*\[CapitalSigma][fin[t] + fit[t] + mat[t], psi0] + 
   pit*fit[t]*\[CapitalSigma][fin[t] + fit[t] + mat[t], psi0] - 
   enz[t]/tau,
 oxi'[t] == -betan*fin[t]*oxi[t] + fo,
 glu'[t] == -betat*fit[t]*glu[t] + fg,

 fin[0] == 0.45, fit[0] == 0.005, mat[0] == 0.2, enz[0] == 0.2, 
 oxi[0] == 0.25, glu[0] == 0.16},
  {fin[t], fit[t], mat[t], enz[t], oxi[t], glu[t]}, {t, 0, 
 80}]][[1, 1, 2]]
 Plot[solucion[t], {t, 0, 80}, PlotRange -> Full]

UPDATE

I could solve my problem of other way. i update my post in case someone needs to do the same.

my personal solution to graph was plot different solutions for each case (equation) and together all them using Show and use your proposal in the comments for plot properly my results. Here my code for different cases in a image:

enter image description here

I don't know how close or conclude this post. thx for everyone's help.

$\endgroup$
  • $\begingroup$ Ticks $\endgroup$ – user6014 Nov 6 '17 at 21:38
  • 1
    $\begingroup$ Try using Ticks -> {Automatic, ChartingScaledTicks["Linear"][##, {10, 10}] &}`. $\endgroup$ – Carl Woll Nov 6 '17 at 21:42
  • $\begingroup$ The above comments give the answer, but don't do it. It's just noise. $\endgroup$ – Alan Nov 6 '17 at 22:21
  • $\begingroup$ Try Ticks but it does not work I will put my complete code in the publication $\endgroup$ – Rodrigo López Nov 6 '17 at 22:43
  • 1
    $\begingroup$ Alternatively, if you want to use your code for the graph on the right, you can use AxesOrigin -> {0, 0} to get the axes to cross at the origin. $\endgroup$ – Anne Nov 6 '17 at 23:20
3
$\begingroup$

Here's my suggestion from the comments:

Plot[
    solucion[t],
    {t, 0, 80},
    PlotRange->{0, .55},
    Ticks->{Automatic, Charting`ScaledTicks["Linear"][##, {11,5}]&}
]

enter image description here

Update

The OP wants to use PlotRange->Full and still have the axes origin included. For this, one can modify my answer to use @Anne's suggestion of AxesOrigin:

Plot[
    solucion[t],
    {t, 0, 80},
    PlotRange -> Full,
    AxesOrigin -> {0,0},
    Ticks -> {Automatic, Charting`ScaledTicks["Linear"][##, {12, 5}]&}
]

enter image description here

Note that I had to increase the goal (12) for number of ticks because the y-range is slightly bigger than the {0, .55} I used earlier.

$\endgroup$
  • $\begingroup$ I actually tried your solution before (from your comment). But if the before has only say 5 major ticks, your new plot will not necessarily have the same major ticks? For example, how would your method change Plot[Sin[t],{t,0,2 Pi},PlotRange->{{0,2 Pi},Automatic}] major ticks (there are 5 on the y axis) by dividing each by say 10 as in my example? If it works, it will be much simpler than what I have. $\endgroup$ – Nasser Nov 7 '17 at 0:41
  • $\begingroup$ @Nasser My understanding of the question is the OP wanted more ticks, not that he wanted to divide the ticks by 10. $\endgroup$ – Carl Woll Nov 7 '17 at 0:43
  • $\begingroup$ I see. I think you are right now. I though they wanted the same Tick labels but each scaled down by 10 or such. In this case your method is much simpler. I vote for it. $\endgroup$ – Nasser Nov 7 '17 at 0:49
  • $\begingroup$ @Nasser By the way, it is possible to use Charting`ScaledTicks[{10#&, #/10&}] to scale the ticks down by 10. $\endgroup$ – Carl Woll Nov 7 '17 at 0:51
  • $\begingroup$ @Nasser indeed, in fact the graph changes for each equation (there are 6 coupled equations). i.e, if you change in the code "[[1, 1, 2]]" by this other "[[1, 2, 2]]" or "[[1, 3, 2]]" (appear before Plot) the plot has other values and does not adjust automatically. My intention is that in each graph the values are adjusted automatically $\endgroup$ – Rodrigo López Nov 7 '17 at 0:53
1
$\begingroup$

Using Wizard's answer at extract-ticks-from-plot and after getting the major ticks, changed them by dividing by 10 each label, and putting it all back.

You did not give an example, so made one up. In this example, just changed the labels by diving each major tick by 10

Mathematica graphics

f[t_]:=Sin[t];
p1=Plot[f[t],{t,0,2 Pi},BaseStyle->14,ImageSize->300,PlotLabel->"Before"];
yTicks=Charting`FindTicks[{0,1},{0,1}]@@PlotRange[p][[2]];
idxEnd=First@Last@Position[yTicks,{at_,NumberForm[label_,rest_]}];
major=yTicks[[1;;idxEnd]];
major=major/.NumberForm[lbl_,__]:>lbl/10.;
yTicks[[1;;idx]]=major;
p2=Plot[f[t],{t,0,2 Pi},Ticks->{Automatic,yTicks},BaseStyle->14,
  ImageSize->300,PlotLabel->"After"];

Grid[{{p1,p2}}]

Here is the idea: First the yticks are obtained using the line (from the above answer link)

  yTicks=Charting`FindTicks[{0,1},{0,1}]@@PlotRange[p][[2]];

Then the major ticks are extraced from the above using the lines

idxEnd=First@Last@Position[yTicks,{at_,NumberForm[label_,rest_]}];
major=yTicks[[1;;idxEnd]]

Then each label is changed using the line

major=major/.NumberForm[lbl_,__]:>lbl/10.;

Then it is put back in yTicks using the line

yTicks[[1;;idx]]=major;

Now the plot is generated again, but using the new yTicks using the line

Plot[f[t],{t,0,2 Pi},Ticks->{Automatic,yTicks}]

But this seems a bit complicated and I am sure there are easier ways to do this. You could always make your own Ticks function ofcourse but need to make sure the minor and major ticks remain there.

The advantage of Charting`FindTicks seems to be that you will be using the same major ticks location as in the original plot and do not have mess things up if you make your own new tick locations.

$\endgroup$
  • $\begingroup$ they suggested me in the comments to use: Plot[solucion[t], {t, 0, 80}, PlotRange -> {0, .55}, Ticks -> {Automatic, Range[0, .55, .05]}] it's almost what I want, however, the plot changes in different situations and it does not adjust automatically $\endgroup$ – Rodrigo López Nov 7 '17 at 0:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.