Skip to content

Commit

Permalink
Update 06 Plot Data.html
Browse files Browse the repository at this point in the history
  • Loading branch information
DerekMelchin authored Oct 24, 2023
1 parent e96cf7d commit 755f95b
Showing 1 changed file with 21 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,31 @@

<p>Follow these steps to plot line charts using <span class="python">built-in methods</span><span class="csharp"><code>Plotly.NET</code> package</span>:</p>

<ol>
<ol>
<li>Get some historical data.</li>
<div class="section-example-container">
<pre class='csharp'>var history = qb.GetFundamental(symbols, "ValuationRatios.PERatio", new DateTime(2014, 1, 1), new DateTime(2015, 1, 1));</pre>
<pre class='python'>history = qb.GetFundamental(symbols, "ValuationRatios.PERatio", datetime(2014, 1, 1), datetime(2015, 1, 1))</pre>
</div>

<li class="csharp">Load the Plotly.NET package.</li>
<div class="csharp section-example-container">
<pre class='csharp'>#r "../Plotly.NET.dll"
#r "../Plotly.NET.Interactive.dll"

using Plotly.NET;
using Plotly.NET.Interactive;
using Plotly.NET.LayoutObjects;</pre>
</div>

<li class="csharp">Create <code>Line</code> charts.</li>
<li class="csharp">Create <code>Line</code> objects for each <code>Symbol</code>.</li>
<div class="csharp section-example-container">
<pre class='csharp'>var chart1 = Chart2D.Chart.Line&lt;DateTime, decimal, string&gt;(
history.Select(x => (DateTime)x.Time),
history.Select(x => (decimal)x[aapl]),
Name: "AAPL"
);
var chart2 = Chart2D.Chart.Line&lt;DateTime, decimal, string&gt;(
history.Select(x => (DateTime)x.Time),
history.Select(x => (decimal)x[goog]),
Name: "GOOG"
<pre class='csharp'>var charts = symbols.Select(
symbol => Chart2D.Chart.Line&lt;DateTime, decimal, string&gt;(
history.Select(x => (DateTime)x.Time),
history.Select(x => (decimal)x[symbol]),
Name: symbol.Value
)
);</pre>
</div>

Expand All @@ -29,7 +36,7 @@
xAxis.SetValue("title", "Time");
LinearAxis yAxis = new LinearAxis();
yAxis.SetValue("title", "PE Ratio");
Title title = Title.init("AAPL & GOOG PE Ratio");
Title title = Title.init("PE Ratios Over Time");

Layout layout = new Layout();
layout.SetValue("xaxis", xAxis);
Expand All @@ -39,7 +46,7 @@

<li class="csharp">Combine the charts and assign the <code>Layout</code> to the chart.<br></li>
<div class="csharp section-example-container">
<pre class='csharp'>var chart = Plotly.NET.Chart.Combine(new []{chart1, chart2});
<pre class='csharp'>var chart = Plotly.NET.Chart.Combine(charts);
chart.WithLayout(layout);</pre>
</div>

Expand All @@ -57,4 +64,4 @@
</ol>

<img class="python docs-image" src="https://cdn.quantconnect.com/i/tu/equity-fundamental-data-plot.jpg" alt="Line plot of PE ratio of US Equities">
<img class="csharp docs-image" src="https://cdn.quantconnect.com/i/tu/equity-fundamental-data-plot-csharp.png" alt="Line plot of PE ratio of AAPL & GOOG">
<img class="csharp docs-image" src="https://cdn.quantconnect.com/i/tu/pe-ratios-over-time-plotly-net.png" alt="Line plot of PE ratio of US Equities">

0 comments on commit 755f95b

Please sign in to comment.