GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • F#
  • Python (v7.1.0)
  • R
  • Julia
  • Javascript (v4.1.1)
  • ggplot2
  • MATLAB
  • F#
  • Download Studio
  • Studio and Cloud Pricing
  • Dash Enterprise Pricing
  • Getting Started
  • GitHub
  • community.plotly.com

This view

  • Original page
  • New address

GeezerVison is showing plotly.com — Log plots in Fsharp

Quick Reference
On This Page
View open positions at Plotly.
In [1]:
#r "nuget: Newtonsoft.Json, 12.0.3"
#r "nuget: Plotly.NET, 2.0.0-preview.10"
#r "nuget: Plotly.NET.Interactive, 2.0.0-preview.10"
#r "nuget: FSharp.Data"
The below script needs to be able to find the current output cell; this is an easy method to get it.
Installed Packages
  • FSharp.Data, 4.2.4
  • Newtonsoft.Json, 12.0.3
  • Plotly.NET, 2.0.0-preview.10
  • Plotly.NET.Interactive, 2.0.0-preview.10

Loading extensions from Plotly.NET.Interactive.dll

Added Kernel Extension including formatters for Plotly.NET charts.

This page shows examples of how to configure 2-dimensional Cartesian axes to follow a logarithmic rather than linear progression. Configuring gridlines, ticks, tick labels and axis titles on logarithmic axes is done the same was as with linear axes.

Logarithmic Axes¶

In [2]:
open Plotly.NET
open Plotly.NET.LayoutObjects
open FSharp.Data

let data = CsvFile.Load("https://raw.githubusercontent.com/plotly/datasets/master/gapminder2007.csv")

let x = data.Rows |> Seq.map (fun row -> row.GetColumn("gdpPercap"))
let y = data.Rows |> Seq.map (fun row -> row.GetColumn("lifeExp"))

Chart.Scatter(x=x,y=y,mode=StyleParam.Mode.Markers )
|> Chart.withXAxis(LinearAxis.init(AxisType=StyleParam.AxisType.Log))
Out[2]:

Setting the range of a logarithmic axis works the same was as with linear axes: using the XAxis Range and YAxis Range keywords on the Layout.

In the example below, the range of the x-axis is [0, 5] in log units, which is the same as [0, 10000] in linear units.

In [3]:
open Plotly.NET
open Plotly.NET.LayoutObjects
open FSharp.Data

let data = CsvFile.Load("https://raw.githubusercontent.com/plotly/datasets/master/gapminder2007.csv")

let x = data.Rows |> Seq.map (fun row -> row.GetColumn("gdpPercap"))
let y = data.Rows |> Seq.map (fun row -> row.GetColumn("lifeExp"))

Chart.Scatter(x=x,y=y,mode=StyleParam.Mode.Markers )
|> Chart.withXAxis(LinearAxis.init(AxisType=StyleParam.AxisType.Log, Range=StyleParam.Range.MinMax(0.,5.))) // log range: 10^0=1, 10^5=100000
|> Chart.withYAxisStyle(title="lifeExp",MinMax=(0.,100.)) // linear range
Out[3]:
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.