Message Boards Message Boards

1
|
10437 Views
|
14 Replies
|
17 Total Likes
View groups...
Share
Share this post:

[?] Plot given ranges on two axis?

I am new for mathematica. I am confused how to get a graph between two variables on two axis. example is given as:

x = Range[4, 10, 1]

and

y = Range[5,11,1]

how to get a graph between different values of x and y using above.

POSTED BY: Anil Kumar
14 Replies

Hi Anyl, I would it like this: x = Range[4, 10, 1]; y = Range[5, 11, 1]; ListPlot[Partition[Riffle[x, y], 2]]

POSTED BY: Laurens Wachters

... in a clean kernel because you already assigned variables improperly. For example, Valerie defined functions with := which you typed as = and you left off an underscore (which is a pattern matching symbol).

POSTED BY: Neil Singer

enter image description here

POSTED BY: Anil Kumar

Dear Anil,

You must copy the entire code and execute it.

Attachments:

Thank you sir for being kind to reply. It is working now and I got my solution.

POSTED BY: Anil Kumar

Thank you Valeriu Sir! I tried what you suggested but instead of graph I got this value. Set::write: Tag List in {2.4695610^-15,2.4695610^-7,4.9391310^-7,7.4086910^-7,9.8782510^-7,1.2347810^-6,1.4817410^-6,1.7286910^-6,1.9756510^-6,2.222610^-6,2.4695610^-6,2.7165110^-6,2.9634710^-6,3.2104210^-6,3.4573810^-6,3.7043310^-6,3.9512910^-6,<<18>>,8.643410^-6,8.8903510^-6,9.137310^-6,9.3842610^-6,9.6312110^-6,9.87816*10^-6,0.0000101251,0.0000103721,0.000010619,0.000010866,0.0000111129,0.0000113599,0.0000116068,0.0000118538,0.0000121007,<<50>>}[{<<1>>}] is Protected.

POSTED BY: Anil Kumar

Thank you all for being kind enough to reply and special thanks to Valeriu !! But I could not still understand it. I am attaching my code herewith. I want a graph between theta and pressure(p) with theta on y -axis and p on x-axis. I am attaching .nb file also with this post i will be thankful.

nstar=10^21; (*number of adsorption sites available on the surface *)
[Nu]0=10^13;   (* oscllation frequency of nuetral adsorbates*)
S0=10^-2;
[Nu]negative=10^13;   (* oscllation frequency of negatively charged adsorbates*)
m=2.65*10^26;   (* mass of adsorbed molecules*)
k=1.38*10^-23;   (* Boltzmann constant*)
T=298;    (* Operating Temperature*)
q0=1.87*10^-20;   (* binding energy of nuetral adsorbates*)
EF=5*1.6*10^-19;    (* Fermi energy level*)
Ess=5.25*1.6*10^-19;   (* energy level after adion adsorbate chemisorption*)
Es=4.00*1.6*10^-19;   (* energy level of conduction band electrons on the surface*)
p=Range[10^-10,10,10^-2];
Exp[q0/(k*T)];
[Beta]0=S0/nstar*[Nu]0*Sqrt[2*[Pi]*m*k*T]*Exp[q0/(k*T)];
[Beta]=[Beta]0*(1+Exp[(EF-Ess)/(k*T)])*(1+([Nu]negative/[Nu]0)*Exp[-((Es-EF)/(k*T))]^-1  );
[Theta]=([Beta]*p)/(1+[Beta]*p);
Attachments:
POSTED BY: Anil Kumar

It seems you need to plot elementary a graph of a function, i.e.:

nstar = 10^21;    (*number of adsorption sites available on the surface *)
\[Nu]0 = 10^13;   (* oscllation frequency of nuetral adsorbates*)
S0 = 10^-2;
\[Nu]negative = 10^13;   (* oscllation frequency of negatively charged adsorbates*)
m = 2.65*10^26;    (* mass of adsorbed molecules*)
k = 1.38*10^-23;   (* Boltzmann constant*)
T = 298;           (* Operating Temperature*)
q0 = 1.87*10^-20;   (* binding energy of nuetral adsorbates*)
EF = 5*1.6*10^-19;    (* Fermi energy level*)
Ess = 5.25*1.6*10^-19;   (* energy level after adion adsorbate chemisorption*)
Es = 4.00*1.6*10^-19;   (* energy level of conduction band electrons on the surface*)
\[Beta]0 = S0/nstar*\[Nu]0*Sqrt[2*\[Pi]*m*k*T]*Exp[q0/(k*T)];
\[Beta] = \[Beta]0*(1 + Exp[(EF - Ess)/(k*T)])*(1 + (\[Nu]negative/\[Nu]0)*Exp[-((Es - EF)/(k*T))]^-1  );
\[Theta][p_] := (\[Beta]*p)/(1 + \[Beta]*p);
Plot[\[Theta][p], {p, 10^-10, 10}]

Hi Anil,

Here an example of a TwoAxisPlot with a simple relation between two functions

Plot[{Sin[x], 3 Sin[x] + 5 Cos[x]}, {x, 0, 4 Pi}];

The TwoAxisPlot, rescales two plots to appear to have the same range. The ranges of the functions are shown on the left and right sides of the frame:

TwoAxisPlot[{f_, g_}, {x_, x1_, x2_}] := 
 Module[{fgraph, ggraph, frange, grange, fticks, 
   gticks}, {fgraph, ggraph} = 
   MapIndexed[
    Plot[#, {x, x1, x2}, Axes -> True, 
      PlotStyle -> ColorData[1][#2[[1]]]] &, {f, g}]; {frange, 
    grange} = (PlotRange /. AbsoluteOptions[#, PlotRange])[[
      2]] & /@ {fgraph, ggraph}; fticks = N@FindDivisions[frange, 5];
  gticks = 
   Quiet@Transpose@{fticks, 
      ToString[NumberForm[#, 2], StandardForm] & /@ 
       Rescale[fticks, frange, grange]};
  Show[fgraph, 
   ggraph /. 
    Graphics[graph_, s___] :> 
     Graphics[
      GeometricTransformation[graph, 
       RescalingTransform[{{0, 1}, grange}, {{0, 1}, frange}]], s], 
   Axes -> False, Frame -> True, 
   FrameStyle -> {ColorData[1] /@ {1, 2}, {Automatic, Automatic}}, 
   FrameTicks -> {{fticks, gticks}, {Automatic, Automatic}}]]

The combined plot illustrates the fact that for some and :

TwoAxisPlot[{Sin[x], 3 Sin[x] + 5 Cos[x]}, {x, 0, 4 Pi}]

enter image description here

I hope this will help. Regards,....Jos

Note: See a further example with the function 'Overlay' on

TwoAxisPlot with 'Overlay'

POSTED BY: Jos Klaps

Hi Anil,

Here an example of a TwoAxisPlot with a simple relation between two functions

Plot[{Sin[x], 3 Sin[x] + 5 Cos[x]}, {x, 0, 4 Pi}];

The TwoAxisPlot, rescales two plots to appear to have the same range. The ranges of the functions are shown on the left and right sides of the frame:

TwoAxisPlot[{f_, g_}, {x_, x1_, x2_}] := 
 Module[{fgraph, ggraph, frange, grange, fticks, 
   gticks}, {fgraph, ggraph} = 
   MapIndexed[
    Plot[#, {x, x1, x2}, Axes -> True, 
      PlotStyle -> ColorData[1][#2[[1]]]] &, {f, g}]; {frange, 
    grange} = (PlotRange /. AbsoluteOptions[#, PlotRange])[[
      2]] & /@ {fgraph, ggraph}; fticks = N@FindDivisions[frange, 5];
  gticks = 
   Quiet@Transpose@{fticks, 
      ToString[NumberForm[#, 2], StandardForm] & /@ 
       Rescale[fticks, frange, grange]};
  Show[fgraph, 
   ggraph /. 
    Graphics[graph_, s___] :> 
     Graphics[
      GeometricTransformation[graph, 
       RescalingTransform[{{0, 1}, grange}, {{0, 1}, frange}]], s], 
   Axes -> False, Frame -> True, 
   FrameStyle -> {ColorData[1] /@ {1, 2}, {Automatic, Automatic}}, 
   FrameTicks -> {{fticks, gticks}, {Automatic, Automatic}}]]

The combined plot illustrates the fact that for some and :

TwoAxisPlot[{Sin[x], 3 Sin[x] + 5 Cos[x]}, {x, 0, 4 Pi}]

enter image description here

I hope this will help. Regards,....Jos

POSTED BY: Jos Klaps

I am not sure what you have in mind. This uses the output of NumberLinePlot:

Show[NumberLinePlot[Range[4, 10, 1]], 
 NumberLinePlot[Range[5, 11, 1]] /. Point[{x_, y_}] :> Point[{y, x}],
 PlotRange -> All, AspectRatio -> Automatic,
 Axes -> True, AxesOrigin -> {0, 0}]
POSTED BY: Gianluca Gorni

Valeriu,

I like that! It is a true Graph...

Regards

POSTED BY: Neil Singer

Or, may be you need such a graph?

Graph[Flatten@Table[x[[i]] -> y[[j]], {i, Length@x}, {j, Length@y}]]

enter image description here

See ListLinePlot or ListPlot.

To interleave your data in the right format:

ListLinePlot[Transpose[{x, y}]]

Regards

POSTED BY: Neil Singer
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract