<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:DengXian;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:"\@DengXian";
panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-GB" link="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">Hi All,<o:p></o:p></p>
<p class="MsoNormal"><br>
I am trying to plot a loglog plot with two lines, one for my error and one with a slope of 1. Plotting only the error or only the slope of 1 works fine, but I like both lines in the same plot (that doesn’t work till now). Does somebody know how to solve this?
Find a code snipet below: <br>
<br>
<o:p></o:p></p>
<p class="MsoNormal">PetscDraw draw;<o:p></o:p></p>
<p class="MsoNormal">PetscDrawLG lg;<o:p></o:p></p>
<p class="MsoNormal">PetscDrawAxis axis;<o:p></o:p></p>
<p class="MsoNormal">PetscReal xc, yc;<o:p></o:p></p>
<p class="MsoNormal">PetscDrawCreate(PETSC_COMM_SELF, NULL, "Log(Error) vs Log(dx)", PETSC_DECIDE, PETSC_DECIDE, PETSC_DRAW_HALF_SIZE, PETSC_DRAW_HALF_SIZE, &draw);<o:p></o:p></p>
<p class="MsoNormal">PetscDrawSetFromOptions(draw);<o:p></o:p></p>
<p class="MsoNormal">PetscDrawLGCreate(draw, <span style="background:yellow;mso-highlight:yellow">
2</span>, &lg);<o:p></o:p></p>
<p class="MsoNormal">PetscDrawLGSetUseMarkers(lg, PETSC_TRUE);<o:p></o:p></p>
<p class="MsoNormal">PetscDrawLGGetAxis(lg, &axis);<o:p></o:p></p>
<p class="MsoNormal">PetscDrawAxisSetLabels(axis, NULL, "Log(dx)", "Log(Error)");<br>
<br>
for loop {<o:p></o:p></p>
<p class="MsoNormal">xc = PetscLog10Real(dx);<o:p></o:p></p>
<p class="MsoNormal">yc = PetscLog10Real(error);<o:p></o:p></p>
<p class="MsoNormal">PetscDrawLGAddPoint(lg, &xc, &yc); // to plot the error<o:p></o:p></p>
<p class="MsoNormal"><span style="background:yellow;mso-highlight:yellow">PetscDrawLGAddPoint(lg, &xc, &xc); // to plot line with slope 1</span><o:p></o:p></p>
<p class="MsoNormal">PetscDrawLGDraw(lg);<br>
}<br>
<br>
<o:p></o:p></p>
<p class="MsoNormal">PetscDrawSetPause(draw, -2);<o:p></o:p></p>
<p class="MsoNormal">PetscDrawLGDestroy(&lg);<o:p></o:p></p>
<p class="MsoNormal">PetscDrawDestroy(&draw);<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="color:#24292E">Best regards,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#24292E"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#24292E">Thijs Smit<o:p></o:p></span></p>
</div>
</body>
</html>