{"id":412,"date":"2019-04-23T22:51:17","date_gmt":"2019-04-24T02:51:17","guid":{"rendered":"https:\/\/pressbooks.bccampus.ca\/introtolatex\/?post_type=chapter&#038;p=412"},"modified":"2019-05-08T19:03:10","modified_gmt":"2019-05-08T23:03:10","slug":"plot-solutions","status":"publish","type":"chapter","link":"https:\/\/pressbooks.bccampus.ca\/introtolatex\/chapter\/plot-solutions\/","title":{"raw":"Plot Solutions","rendered":"Plot Solutions"},"content":{"raw":"These answers show one possible solution to each problem. Other ways of solving the problems are also correct.\r\n<ol>\r\n \t<li>The answers below show what portion of the code to change.\r\n<ol>\r\n \t<li><code> \\addplot [<strong>domain=-2:2,<\/strong> samples=100, color=blue]<\/code><\/li>\r\n \t<li><code>\\begin{axis}[axis lines = left, xlabel = $x$, <strong>ylabel = $y$<\/strong>]<\/code><\/li>\r\n \t<li><code>\\addplot [domain=-2:2, samples=100, <strong>color=green<\/strong>]<\/code><\/li>\r\n \t<li><code>\\addplot [domain=-2:2, samples=100, color=blue]\r\n{x^2 + 2*x + 1};<\/code><\/li>\r\n<\/ol>\r\n<table style=\"border-collapse: collapse;width: 96%\" border=\"0\">\r\n<tbody>\r\n<tr>\r\n<td style=\"width: 50%\">[latex]\r\n\\begin{tikzpicture}\r\n\\begin{axis}[ axis lines = left, xlabel = $x$, ylabel = $y$]\r\n\\addplot [ domain=-2:2, samples=100, color=green]\r\n{-x^2 + 3*x + 4};\r\n\\addplot [domain=-2:2, samples=100, color=blue]\r\n{x^2 + 2*x + 1};\r\n\\end{axis}\r\n\\end{tikzpicture}[\/latex]<\/td>\r\n<td style=\"width: 50%\"><code>[\u200clatex]\r\n\\begin{tikzpicture}\r\n\\begin{axis}[ axis lines = left, xlabel = $x$, ylabel = $y$]\r\n\\addplot [ domain=-2:2, samples=100, color=green]\r\n{-x^2 + 3*x + 4};\r\n\\addplot [domain=-2:2, samples=100, color=blue]\r\n{x^2 + 2*x + 1};\r\n\\end{axis}\r\n\\end{tikzpicture}[\/latex]<\/code><\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/li>\r\n \t<li>\r\n<table style=\"border-collapse: collapse;width: 96%\" border=\"0\">\r\n<tbody>\r\n<tr>\r\n<td style=\"width: 50%\">[latex]\r\n\\begin{tikzpicture}\r\n\\begin{axis}[axis lines = left, title=Intersection of Quadratics, xlabel = $x$, ylabel = $y$, legend pos=north west]\r\n\\addplot [domain=-2:2, samples=100, color=green]{-x^2 + 3*x + 4};\r\n\\addplot [domain=-2:2, samples=100, color=blue]{x^2 + 2*x + 1};\r\n\\legend{$-x^2 + 3x + 4$,$x^2 + 2x + 1$}\r\n\\end{axis}\r\n\\end{tikzpicture}[\/latex]<\/td>\r\n<td style=\"width: 50%\"><code>[\u200clatex]\r\n\\begin{tikzpicture}\r\n\\begin{axis}[axis lines = left, <strong>title=Intersection of Quadratics<\/strong>, xlabel = $x$, ylabel = $y$, <strong>legend pos= north west<\/strong>]\r\n\\addplot [domain=-2:2, samples=100, color=green]{-x^2 + 3*x + 4};\r\n\\addplot [domain=-2:2, samples=100, color=blue]{x^2 + 2*x + 1};\r\n<strong>\\legend{$-x^2 + 3x + 4$,$x^2 + 2x + 1$}<\/strong>\r\n\\end{axis}\r\n\\end{tikzpicture}[\/latex]<\/code><\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/li>\r\n \t<li>The first plot below uses a colorbar with <code>point meta rel=axes wide<\/code>, which maps the colorbar to the whole y axis. The second plot uses <code>point meta rel=per plot<\/code> which maps the colorbar to each function on the plot.\r\n<table style=\"border-collapse: collapse;width: 96%\" border=\"0\">\r\n<tbody>\r\n<tr>\r\n<td style=\"width: 50%\">[latex]\r\n\\begin{tikzpicture}\r\n\\begin{axis}[\r\naxis lines = left, title=Intersection of Quadratics, xlabel = $x$, ylabel = $f(x)$, colorbar, point meta rel=axes wide, point meta=y]\r\n\\addplot+[mesh, thick, mark=none] {-x^2 + 3*x + 4};\r\n\\addplot+[mesh, thick, mark=none] {x^2 + 2*x + 1};\r\n\\end{axis}\r\n\\end{tikzpicture}[\/latex]<\/td>\r\n<td style=\"width: 50%\"><code>[\u200clatex]\r\n\\begin{tikzpicture}\r\n\\begin{axis}[axis lines=left, title=Intersection of Quadratics, xlabel=$x$, ylabel=$f(x)$, colorbar, point meta rel=axes wide,  point meta=y]\r\n\\addplot+[mesh, thick, mark=none]\r\n{-x^2 + 3*x + 4};\r\n\\addplot+[mesh, thick, mark=none]\r\n{x^2 + 2*x + 1};\r\n\\end{axis}\r\n\\end{tikzpicture}[\/latex]<\/code><\/td>\r\n<\/tr>\r\n<tr>\r\n<td style=\"width: 50%\">[latex]\r\n\\begin{tikzpicture}\r\n\\begin{axis}[axis lines = left, title=Intersection of Quadratics, xlabel = $x$, ylabel = {$f(x), g(x)$}, colorbar, point meta rel=per plot, point meta=y]\r\n\\addplot+[mesh, thick, mark=none] {-x^2 + 3*x + 4};\r\n\\addplot+[mesh, thick, mark=none] {x^2 + 2*x + 1};\r\n\\end{axis}\r\n\\end{tikzpicture}[\/latex]<\/td>\r\n<td style=\"width: 50%\"><code>[\u200clatex]\r\n\\begin{tikzpicture}\r\n\\begin{axis}[axis lines=left, title=Intersection of Quadratics, xlabel=$x$, ylabel={$f(x), g(x)$}, colorbar, point meta rel=per plot, point meta=y]\r\n\\addplot+[mesh, thick, mark=none]\r\n{-x^2 + 3*x + 4};\r\n\\addplot+[mesh, thick, mark=none]\r\n{x^2 + 2*x + 1};\r\n\\end{axis}\r\n\\end{tikzpicture}[\/latex]<\/code><\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/li>\r\n \t<li>The plot below shows the behavior of [latex]\\frac{1}{x} + \\frac{1}{y}[\/latex] near 0. Note that if you increase the number of samples from 50 to 100, you will exceed the memory allotted for QuickLatex. In general, increasing the number of samples will reduce the responsiveness of your page. So, it is not always desirable to enter larger sample numbers.\r\n<table style=\"border-collapse: collapse;width: 96%\" border=\"0\">\r\n<tbody>\r\n<tr>\r\n<td style=\"width: 50%\">[latex]\r\n\\begin{tikzpicture}\r\n\\begin{axis}\r\n\\addplot3[surf, domain=-2:2, samples=40] {1\/x + 1\/y};\r\n\\end{axis}\r\n\\end{tikzpicture}\r\n[\/latex]<\/td>\r\n<td style=\"width: 50%\"><code>[\u200clatex]\r\n\\begin{tikzpicture}\r\n\\begin{axis}\r\n\\addplot3[surf, domain=-2:2, samples=40] {1\/x + 1\/y};\r\n\\end{axis}\r\n\\end{tikzpicture}\r\n[\/latex]<\/code><\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/li>\r\n \t<li>\r\n<table style=\"border-collapse: collapse;width: 96%\" border=\"0\">\r\n<tbody>\r\n<tr>\r\n<td style=\"width: 50%\">[latex]\r\n\\begin{tikzpicture}\r\n\\begin{axis}[ybar, bar width=7pt,enlarge y limits={0.15,upper},\r\nenlarge x limits=0.15]\r\n\\addplot plot coordinates\r\n{(0,3) (1,2) (2,4) (3,1) (4,2)};\r\n\\addplot plot coordinates\r\n{(0,2) (1,3) (2,6) (3,0) (4,4)};\r\n\\end{axis}\r\n\\end{tikzpicture}\r\n[\/latex]<\/td>\r\n<td style=\"width: 50%\"><code>[\u200clatex]\r\n\\begin{tikzpicture}\r\n\\begin{axis}[ybar, enlarge y limits={0.15,upper},\r\nenlarge x limits=0.15]\r\n\\addplot plot coordinates\r\n{(0,3) (1,2) (2,4) (3,1) (4,2)};\r\n\\addplot plot coordinates\r\n{(0,2) (1,3) (2,6) (3,0) (4,4)};\r\n\\end{axis}\r\n\\end{tikzpicture}\r\n[\/latex]<\/code><\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/li>\r\n<\/ol>","rendered":"<p>These answers show one possible solution to each problem. Other ways of solving the problems are also correct.<\/p>\n<ol>\n<li>The answers below show what portion of the code to change.\n<ol>\n<li><code> \\addplot [<strong>domain=-2:2,<\/strong> samples=100, color=blue]<\/code><\/li>\n<li><code>\\begin{axis}[axis lines = left, xlabel = $x$, <strong>ylabel = $y$<\/strong>]<\/code><\/li>\n<li><code>\\addplot [domain=-2:2, samples=100, <strong>color=green<\/strong>]<\/code><\/li>\n<li><code>\\addplot [domain=-2:2, samples=100, color=blue]<br \/>\n{x^2 + 2*x + 1};<\/code><\/li>\n<\/ol>\n<table style=\"border-collapse: collapse;width: 96%\">\n<tbody>\n<tr>\n<td style=\"width: 50%\">\n<p class=\"ql-center-picture\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/pressbooks.bccampus.ca\/introtolatex\/wp-content\/ql-cache\/quicklatex.com-fa56b3b491435ee7cafd6f67ac6b6f01_l3.png\" height=\"248\" width=\"313\" class=\"ql-img-picture quicklatex-auto-format\" alt=\"Rendered by QuickLaTeX.com\" title=\"Rendered by QuickLaTeX.com\" \/><\/p>\n<\/td>\n<td style=\"width: 50%\"><code>[\u200clatex]<br \/>\n\\begin{tikzpicture}<br \/>\n\\begin{axis}[ axis lines = left, xlabel = $x$, ylabel = $y$]<br \/>\n\\addplot [ domain=-2:2, samples=100, color=green]<br \/>\n{-x^2 + 3*x + 4};<br \/>\n\\addplot [domain=-2:2, samples=100, color=blue]<br \/>\n{x^2 + 2*x + 1};<br \/>\n\\end{axis}<br \/>\n\\end{tikzpicture}[\/latex]<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li>\n<table style=\"border-collapse: collapse;width: 96%\">\n<tbody>\n<tr>\n<td style=\"width: 50%\">\n<p class=\"ql-center-picture\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/pressbooks.bccampus.ca\/introtolatex\/wp-content\/ql-cache\/quicklatex.com-2bb41ce893a20f6ae740e90f354db6f1_l3.png\" height=\"274\" width=\"313\" class=\"ql-img-picture quicklatex-auto-format\" alt=\"Rendered by QuickLaTeX.com\" title=\"Rendered by QuickLaTeX.com\" \/><\/p>\n<\/td>\n<td style=\"width: 50%\"><code>[\u200clatex]<br \/>\n\\begin{tikzpicture}<br \/>\n\\begin{axis}[axis lines = left, <strong>title=Intersection of Quadratics<\/strong>, xlabel = $x$, ylabel = $y$, <strong>legend pos= north west<\/strong>]<br \/>\n\\addplot [domain=-2:2, samples=100, color=green]{-x^2 + 3*x + 4};<br \/>\n\\addplot [domain=-2:2, samples=100, color=blue]{x^2 + 2*x + 1};<br \/>\n<strong>\\legend{$-x^2 + 3x + 4$,$x^2 + 2x + 1$}<\/strong><br \/>\n\\end{axis}<br \/>\n\\end{tikzpicture}[\/latex]<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li>The first plot below uses a colorbar with <code>point meta rel=axes wide<\/code>, which maps the colorbar to the whole y axis. The second plot uses <code>point meta rel=per plot<\/code> which maps the colorbar to each function on the plot.<br \/>\n<table style=\"border-collapse: collapse;width: 96%\">\n<tbody>\n<tr>\n<td style=\"width: 50%\">\n<p class=\"ql-center-picture\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/pressbooks.bccampus.ca\/introtolatex\/wp-content\/ql-cache\/quicklatex.com-d6b38d23045cabf4383292cdec2b1a56_l3.png\" height=\"274\" width=\"374\" class=\"ql-img-picture quicklatex-auto-format\" alt=\"Rendered by QuickLaTeX.com\" title=\"Rendered by QuickLaTeX.com\" \/><\/p>\n<\/td>\n<td style=\"width: 50%\"><code>[\u200clatex]<br \/>\n\\begin{tikzpicture}<br \/>\n\\begin{axis}[axis lines=left, title=Intersection of Quadratics, xlabel=$x$, ylabel=$f(x)$, colorbar, point meta rel=axes wide,  point meta=y]<br \/>\n\\addplot+[mesh, thick, mark=none]<br \/>\n{-x^2 + 3*x + 4};<br \/>\n\\addplot+[mesh, thick, mark=none]<br \/>\n{x^2 + 2*x + 1};<br \/>\n\\end{axis}<br \/>\n\\end{tikzpicture}[\/latex]<\/code><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%\">\n<p class=\"ql-center-picture\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/pressbooks.bccampus.ca\/introtolatex\/wp-content\/ql-cache\/quicklatex.com-8fdd98665b8a02011b5675056f659b6a_l3.png\" height=\"274\" width=\"374\" class=\"ql-img-picture quicklatex-auto-format\" alt=\"Rendered by QuickLaTeX.com\" title=\"Rendered by QuickLaTeX.com\" \/><\/p>\n<\/td>\n<td style=\"width: 50%\"><code>[\u200clatex]<br \/>\n\\begin{tikzpicture}<br \/>\n\\begin{axis}[axis lines=left, title=Intersection of Quadratics, xlabel=$x$, ylabel={$f(x), g(x)$}, colorbar, point meta rel=per plot, point meta=y]<br \/>\n\\addplot+[mesh, thick, mark=none]<br \/>\n{-x^2 + 3*x + 4};<br \/>\n\\addplot+[mesh, thick, mark=none]<br \/>\n{x^2 + 2*x + 1};<br \/>\n\\end{axis}<br \/>\n\\end{tikzpicture}[\/latex]<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li>The plot below shows the behavior of <img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/pressbooks.bccampus.ca\/introtolatex\/wp-content\/ql-cache\/quicklatex.com-d74435529f17a706b077c2a81ec02c32_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#120;&#125;&#32;&#43;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#121;&#125;\" title=\"Rendered by QuickLaTeX.com\" height=\"21\" width=\"33\" style=\"vertical-align: -7px;\" \/> near 0. Note that if you increase the number of samples from 50 to 100, you will exceed the memory allotted for QuickLatex. In general, increasing the number of samples will reduce the responsiveness of your page. So, it is not always desirable to enter larger sample numbers.<br \/>\n<table style=\"border-collapse: collapse;width: 96%\">\n<tbody>\n<tr>\n<td style=\"width: 50%\">\n<p class=\"ql-center-picture\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/pressbooks.bccampus.ca\/introtolatex\/wp-content\/ql-cache\/quicklatex.com-2d106cf7ecc4eafc7ca33586667f3867_l3.png\" height=\"233\" width=\"301\" class=\"ql-img-picture quicklatex-auto-format\" alt=\"Rendered by QuickLaTeX.com\" title=\"Rendered by QuickLaTeX.com\" \/><\/p>\n<\/td>\n<td style=\"width: 50%\"><code>[\u200clatex]<br \/>\n\\begin{tikzpicture}<br \/>\n\\begin{axis}<br \/>\n\\addplot3[surf, domain=-2:2, samples=40] {1\/x + 1\/y};<br \/>\n\\end{axis}<br \/>\n\\end{tikzpicture}<br \/>\n[\/latex]<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li>\n<table style=\"border-collapse: collapse;width: 96%\">\n<tbody>\n<tr>\n<td style=\"width: 50%\">\n<p class=\"ql-center-picture\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/pressbooks.bccampus.ca\/introtolatex\/wp-content\/ql-cache\/quicklatex.com-fce6153cf09b96e6b0ad41197e28c267_l3.png\" height=\"242\" width=\"272\" class=\"ql-img-picture quicklatex-auto-format\" alt=\"Rendered by QuickLaTeX.com\" title=\"Rendered by QuickLaTeX.com\" \/><\/p>\n<\/td>\n<td style=\"width: 50%\"><code>[\u200clatex]<br \/>\n\\begin{tikzpicture}<br \/>\n\\begin{axis}[ybar, enlarge y limits={0.15,upper},<br \/>\nenlarge x limits=0.15]<br \/>\n\\addplot plot coordinates<br \/>\n{(0,3) (1,2) (2,4) (3,1) (4,2)};<br \/>\n\\addplot plot coordinates<br \/>\n{(0,2) (1,3) (2,6) (3,0) (4,4)};<br \/>\n\\end{axis}<br \/>\n\\end{tikzpicture}<br \/>\n[\/latex]<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<\/ol>\n","protected":false},"author":671,"menu_order":4,"template":"","meta":{"pb_show_title":"on","pb_short_title":"","pb_subtitle":"","pb_authors":[],"pb_section_license":""},"chapter-type":[],"contributor":[],"license":[],"class_list":["post-412","chapter","type-chapter","status-publish","hentry"],"part":204,"_links":{"self":[{"href":"https:\/\/pressbooks.bccampus.ca\/introtolatex\/wp-json\/pressbooks\/v2\/chapters\/412","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pressbooks.bccampus.ca\/introtolatex\/wp-json\/pressbooks\/v2\/chapters"}],"about":[{"href":"https:\/\/pressbooks.bccampus.ca\/introtolatex\/wp-json\/wp\/v2\/types\/chapter"}],"author":[{"embeddable":true,"href":"https:\/\/pressbooks.bccampus.ca\/introtolatex\/wp-json\/wp\/v2\/users\/671"}],"version-history":[{"count":25,"href":"https:\/\/pressbooks.bccampus.ca\/introtolatex\/wp-json\/pressbooks\/v2\/chapters\/412\/revisions"}],"predecessor-version":[{"id":813,"href":"https:\/\/pressbooks.bccampus.ca\/introtolatex\/wp-json\/pressbooks\/v2\/chapters\/412\/revisions\/813"}],"part":[{"href":"https:\/\/pressbooks.bccampus.ca\/introtolatex\/wp-json\/pressbooks\/v2\/parts\/204"}],"metadata":[{"href":"https:\/\/pressbooks.bccampus.ca\/introtolatex\/wp-json\/pressbooks\/v2\/chapters\/412\/metadata\/"}],"wp:attachment":[{"href":"https:\/\/pressbooks.bccampus.ca\/introtolatex\/wp-json\/wp\/v2\/media?parent=412"}],"wp:term":[{"taxonomy":"chapter-type","embeddable":true,"href":"https:\/\/pressbooks.bccampus.ca\/introtolatex\/wp-json\/pressbooks\/v2\/chapter-type?post=412"},{"taxonomy":"contributor","embeddable":true,"href":"https:\/\/pressbooks.bccampus.ca\/introtolatex\/wp-json\/wp\/v2\/contributor?post=412"},{"taxonomy":"license","embeddable":true,"href":"https:\/\/pressbooks.bccampus.ca\/introtolatex\/wp-json\/wp\/v2\/license?post=412"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}