What I am trying to do is plot pH values on the y-axis against Vb values on the x-axis and I would need to specify the y-axis range as 0-14 and the x-axis range as 0-20..
Both data sets need to be on the same plot/axes.
Based on how that looks, I’m guessing that I misinterpreted something. But maybe there is enough there for you to fiddle with until you get what you want.
That’s exactly what I wanted - many, many thanks. You haven’t misinterpreted anything, it just looks strange because I only gave you the start of the data, In practice the pH values range from 2.9 to 12.5 and then it looks more sensible
Presumably, I can now modify ListPlot to do things like
Adjust line and marker styles and colours
Add axis titles
Add gridlines
Add a plot title
Add a legend
Change axis labels fonts and sizes
and anything else I can think of? If so, it will then just be a case of finding where all these options are in the documentation - shouldn’t be too difficult.
I have checked the documentation but I am still not clear why “,2” is needed in Reverse[dataPairs1,2]
I know it means reverse the elements at level 2 but what is level 2 ?
Also, in the same document I have
Plot[Vb[pH, Ca, Cb, pKa, pKb, Kw, Va], {pH, 2.9, 12.5}]
but again the axes are the “wrong” way round. Vb comes from
In short, each expressions in Mathematica is ultimately a tree. A level is all of the sub-expressions at a particular depth in the tree (usually). You can use Level to extract a level (or levels). Just be careful, because the documentation can sometimes be “loose” with the term “level”–sometimes it means a literal Level and sometimes it’s more like depth. Also be careful about negative levels, which count up from the bottom of the expression tree (so for unbalanced trees the sub-expressions at the same negative level won’t be at the same depth). Anyway, it’s too much info to put into a reply. You’ll need to read the documentation and play around with examples.
As far as I know, Plot will always be arranged with the independent variable on the horizontal axis (but I honestly wouldn’t be surprised if I were wrong and there is some option that affected this). So, you either need to find the inverse function or use your function to generate a list of points that you can deal with like we already did with your dataPairs1 example.
For completeness, I’ll mention that you might be able to extract the data from the underlying Graphics expression that Plot produces. You could manipuate that raw data and create a new plot. But this would be a desperate last resort.
Thank you.
I did take a look at those links and, to be honest, levels are something that I probably won’t need to concern myself with. Having said that, I can see myself possibly having a use for the Head function.
I’ll reply to your post about plots separately.
Plot will always be arranged with the independent variable on the horizontal axis
Blockquote
I suspected as much. Finding the inverse function is what I am effectively doing in a second document. The first and simpler document derives Vb from pH (i.e. input pH values, output Vb values). The second document does the opposite. I’ll stick with generating a list of points …
Life is too short for me even to consider your last suggestion - that would indeed be a desperate last resort.