Message Boards Message Boards

0
|
1923 Views
|
3 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Showing two plots on the same axes

Posted 1 year ago

I have the following two plots:

Plot[pH /@ 
  SolveValues[makeRelationEquation[ Ka[pKa1], Kb[pKb], Ca1, Cb1, Va], 
   H], {Vb, 0, 20}, PlotLabel -> "Titration by Vb", 
 AxesLabel -> {"Vb", "pH"}, ImageSize -> 500]

Plot[pH /@ 
      SolveValues[makeRelationEquation[ Ka[pKa2], Kb[pKb], Ca2, Cb2, Va], 
       H], {Vb, 0, 20}, PlotLabel -> "Titration by Vb", 
     AxesLabel -> {"Vb", "pH"}, ImageSize -> 500]

Both plots are working perfectly but I have made several attempts to show both plots on the same pair of axes and I can't seem to get it right. Any help will be highly appreciated. Thanks.

POSTED BY: Paul Newton
3 Replies
Posted 1 year ago

I have solved the issue of the tick marks using FrameTicks

FrameTicks -> {{{0, 2, 4, 6, 8, 10, 12, 14}, 
   None}, {{0, 5, 10, 15, 20}, None}}

I will raise a new discussion regarding adding a legend when using CombinePlots. Thank you for your help Daniel.

POSTED BY: Paul Newton
Posted 1 year ago

Thank you. The second of those seems to be the more appropriate and I have been experimenting with that approach. Most things are working fine but I have two issues with the result.

One is that I can't seem to get the y-axis major tick marks and labels where I want them (and where I think they should be). The range of the y-axis is 0-14 and I want the major tick marks and labels to be at intervals of 2 but in fact they are at 0, 2.5, 5.0, 7.5, 10.0 and 12.5.

The other issue is that I am using this to place a legend:

PlotLegends -> 
    Placed[LineLegend[{legend1, legend2}, 
      LegendFunction -> (Framed[#, FrameMargins -> -2, 
          Background -> White, FrameStyle -> Directive[Black]] &), 
      LegendLayout -> "Row", LegendMarkerSize -> {{8, 8}}, 
      LabelStyle -> {FontSize -> 10}], {Right, Bottom}]

and this is not working at all (exactly the same code is used to place a legend on a different plot elsewhere in the notebook and it works fine). I am attaching the notebook and a file containing some required data. The relevant code is in a function named makePlot2.

Elsewhere in the same notebook I have another plot with two sets of data and I am using this approach:

ListLinePlot[{Reverse[dataPairs1, 2], Reverse[dataPairs2, 2]}, 
 Frame -> True, lots more options]

and that works really well so I was hoping to do something very similar again but, as I said in my original post, I cannot seem to get it to work,

POSTED BY: Paul Newton
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