Log Plots in Julia

How to make Log plots in Julia with Plotly.


Plotly is known for its graphing libraries, but it's also a broader ecosystem for building interactive data apps, AI data analysis tools, and deploying and hosting Dash apps. Explore the full set of tools and platforms designed to help turn data into action. Discover Plotly.

Note: We are retiring documentation for R, MATLAB, Julia, and F#. Learn more about this change here.

Logarithmic Axes

using PlotlyJS, CSV, DataFrames

df = dataset(DataFrame, "gapminder")
df07 = df[df.year .== 2007, :]

plot(
    df07,
    x=:gdpPercap, y=:lifeExp, hover_name=:county, mode="markers",
    Layout(xaxis_type="log")
)

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. Note that you cannot set the range to include 0 or less.

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.

using PlotlyJS, CSV, DataFrames

df = dataset(DataFrame, "gapminder")
df07 = df[df.year .== 2007, :]

plot(
    df07,
    x=:gdpPercap, y=:lifeExp, hover_name=:county, mode="markers",
    Layout(xaxis=attr(type="log", range=[0, 5]), yaxis_range=[0, 100])
)