Intersection Symbol in Latex with PyPlotJS

Hi all,

I am playing around by creating venn diagram today, I want to know why I can’t make the intersection symbol appeared? Is it impossible? Thanks

Here is the code:

using PlotlyJS, LaTeXStrings

# Create scatter trace of text labels
p = plot(scatter(
    x=[1, 1.75, 2.5, 1.75],
    y=[1, 1, 1, 2.5],
    text=["A", L"A \cap B", "B", "C"],
    mode="text",
    textfont=attr(
        color="black",
        size=18,
        family="Arail",
    )
))

# Update axes properties

update_xaxes!(p,
    showticklabels=false,
    showgrid=false,
    zeroline=false,
)

update_yaxes!(p,
    showticklabels=false,
    showgrid=false,
    zeroline=false,
)

relayout!(
    p,
    margin=attr(l=20, r=20, b=100),
    height=600, width=800,
    plot_bgcolor="white",
    # Add circles
    shapes=[
        circle(
            line_color="blue", fillcolor="blue",
            x0=0, y0=0, x1=2, y1=2,
            opacity=0.3, xref="x", yref="y"
        ),
        circle(
            line_color="gray", fillcolor="gray",
            x0=1.5, y0=0, x1=3.5, y1=2,
            opacity=0.3, xref="x", yref="y"
        )
	,
        circle(
            line_color="green", fillcolor="green",
            x0=0.75, y0=1.5, x1=2.75, y1=3.5,
            opacity=0.3, xref="x", yref="y"
        )
    ]
)

p

Did you figure this one out here?

Haha that’s my old question, yes still not working, I save it to html but it is not working like the old thread/forum.

this is the code:

using LaTeXStrings, Plots
plotlyjs()

# Create scatter trace of text labels
p = plot(scatter(
    x=[1, 1.75, 2.5, 1.75],
    y=[1, 1, 1, 2.5],
    text=["A", L"A \cap B", "B", "C"],
    mode="text",
    textfont=attr(
        color="black",
        size=18,
        family="Arail",
    ),
    extra_plot_kwargs = KW(
               :include_mathjax => "cdn",
               :yaxis => KW(:automargin => true),
               :xaxis => KW(:domain => "auto")
               ),
))

# Update axes properties

update_xaxes!(p,
    showticklabels=false,
    showgrid=false,
    zeroline=false,
)

update_yaxes!(p,
    showticklabels=false,
    showgrid=false,
    zeroline=false,
)

relayout!(
    p,
    margin=attr(l=20, r=20, b=100),
    height=600, width=800,
    plot_bgcolor="white",
    # Add circles
    shapes=[
        circle(
            line_color="blue", fillcolor="blue",
            x0=0, y0=0, x1=2, y1=2,
            opacity=0.3, xref="x", yref="y"
        ),
        circle(
            line_color="gray", fillcolor="gray",
            x0=1.5, y0=0, x1=3.5, y1=2,
            opacity=0.3, xref="x", yref="y"
        )
	,
        circle(
            line_color="green", fillcolor="green",
            x0=0.75, y0=1.5, x1=2.75, y1=3.5,
            opacity=0.3, xref="x", yref="y"
        ),
    ]
)

#show image
#p
PlotlyJS.savefig(p, "myimage.html")

To get the right rendering for $A\cap B$, type the string "A∩B", where ∩ is the html code for \cap, or
the string "A\u2229 B", with \u2229, the unicode for \cap: https://unicode-table.com/en/2229/ .

2 Likes

Thanks a lot,

the string is working (thus I do not need to use kwargs anymore).

But the unicode \u2229 is not working with kwargs and html image.

I want to know the list of strings like ∩ that can be used as replacement for Latex strings

Usually I’m googling: “the unicode and html for Latex \symbol”, and there are a lot of sites displaying both.

1 Like

There’s a Julia package for that, too. :joy:

4 Likes