Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! ✅Check out the new docs.

Customizing a heatmap in PlotlyJS.jl

Hi,

I’m new to programming and am learning Julia as a first language. I’m creating a heatmap using the PlotlyJS.jl package, a julia wrapper/API for plotly.JS. I’m looking for help making a custom heatmap using the Julia code included below. This runs and produces a heatmap, but I would like to make several changes to it. And all of the keys I defined (yflip,name,text,etc.) have no effect on the graphic generated. I’ve read the documentation, examples provided by the package developer, and plotly.js heatmap reference material and can not get the syntax right in Julia. I’ve included my code, the output graphic that is produced, and a manually created draft of the formatting I’d like to achieve eventually.

Thanks in advance for your help. Here is the code I’m using:

#Define custom heatmap function

function my_heatmap()
    trace = heatmap(

    z=output_for_plotly,

    )
    
    yflip=true,
    name="Title Here",
    text=["A-1", "A-2", "A-3", "A-4", "A-5"],
    textposition="top center",
    textfont_family="Raleway, sans-serif"
    plot(trace)

end

#Call my_heatmap function and save graphic as pdf
my_heatmap()
PlotlyJS.savefig(heatmap2(), "test_Dec15.pdf")

Here is the output now:

Here is what I’d like it to look like, except with the rows and columns transposed by yflip=true because the function swaps my rows and columns for some reason. I’d also like to adjust the color assignation to values.

    textposition="top center",
    textfont_family="Raleway, sans-serif"

are not valid plotly.js attributes. You can look up https://plot.ly/javascript/reference/#heatmap for the most up-to-date list of valid attributes.

Hi @etienne, thank you for your reply. I am writing in Julia’s wrapper for plotly.js and the syntax is slightly different from plotly.js. I got the attributes above from an example in the documentation for plotlyJS.jl.

I have used the reference you provided but do not see options to add a “title” or even axis labels to a heatmap in the list of attributes you linked to. I’m imagine these are basic features and I’m missing something. I don’t know whether plotly.js attributes work across different trace types, but have looked in the link you provided and don’t see these options.