Search code examples
plottextjuliaoverflow

Julia: plot with a really large title


I have to make a plot with a long title but the words overflow from the picture instead of breaking into two or three lines. How can I avoid this text overflow.

using LinearAlgebra
x = y = range(-3, stop = 3, length = 100)
surface(x, y, (x, y) -> sinc(norm([x, y])), title="A very long title with a lot of simple words none of them are really large")

enter image description here


Solution

  • using LinearAlgebra
    using Plots
    gr()
    x = y = range(-3, stop = 3, length = 100)
    surface(x, y, (x, y) -> sinc(norm([x, y])), title="A very long title with \na lot of simple words none of them \nare really large")
    

    enter image description here

    in case you are using plotly and plotlyjs, you need to use the html line break argument <br>

    using LinearAlgebra
    using Plots
    plotlyjs()
    x = y = range(-3, stop = 3, length = 100)
    surface(x, y, (x, y) -> sinc(norm([x, y])), title="A very long title with <br>a lot of simple words none of them <br>are really large")
    

    enter image description here