Forum Replies Created

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • bastien
    Member

    Dear Xaveer,

    Thank you for your answer. I get the same error message (using Nazca 0.5.12, Matplotlib 3.2.2, Python 3.7.3). I came across that error in a more complex code and wrongly identified the faulty line. It looks like the error is indeed coming from matplotlib (no error with export to gds) and not from the instantiation; sorry for the confusion. I guess the take home message is that one should be careful when using sympy types…

    in reply to: how to get the matplolib figure? #6163
    bastien
    Member

    Great!

    Would it be possible to have a kwarg to return the figure in nd.export_plotly() so that it can be updated later on? For instance:

    
    fig = nd.export_plotly(return_figure = True)
    
    fig.add_annotation(...)
    

    return_figure = False could be set as default to keep it consistent with other export functions.

    Bastien

    in reply to: how to get the matplolib figure? #6161
    bastien
    Member

    Dear Ronald,

    Plotly is indeed more oriented for use in a web browser and it’s my visualization tool of choice in Jupyter lab. You might need to install an extension to get it to work in Jupyter though. You do not need an account to do all the basic plotting, as far as I understand you need an account only if you want to save plots on their servers (I remember this really confused me as well when I started using it a couple years ago but that has been somewhat clarified since version 4).

    It should be fairly easy to implement a class with the methods you mentioned and I could contribute code when I’ve some time. Is there a good place for that?

    Bastien

    in reply to: how to get the matplolib figure? #6153
    bastien
    Member

    Hi Ronald,

    Thanks for your answer. I am aware of export_plt() and of the clear=False option and this isn’t exactly what I was looking for.  Thanks for pointing at the class, I looked a bit into it and saw that you just need the coordinates of the vertices making up a cell and with help of that post I came up with something that works pretty well for what I had in mind (adding annotation to document a library of layouts or having two subplots side by side). Here is a code snippet demonstrating it in case someone’s interested:

    import plotly.graph_objects as go
    
    nd.clear_layout()
    a = nd.strt(width=5, layer = 1).put()
    b = nd.bend( width=5, layer = 1).put()
    coord = []
    
    for NT in nd.cell_iter(nd.cfg.defaultcell, flat=True):
        if NT.cell_start:
            print(f"\ncell: '{NT.cell.cell_name}'")
            for i, (pgon, points, bbox) in enumerate(NT.iters['polygon']):
               #print(f"{i}: points: {points}, layer: '{pgon.layer}'")
               coord.append(points)
    
    x0 = [i[0] for i in coord[0]]
    x0.append(x0[0]) #to connect last point to first point in the plot
    y0 = [i[1] for i in coord[0]]
    y0.append(y0[0]) #to connect last point to first point in the plot
    x1 = [i[0] for i in coord[1]]
    x1.append(x1[0])
    y1 = [i[1] for i in coord[1]]
    y1.append(y1[0])
    
    fig = go.Figure([
        go.Scatter(x=x0, y=y0, fill="toself", marker=dict(opacity=0), name="arc layer1"),
        go.Scatter(x=x1, y=y1, fill="toself", marker=dict(opacity=0) )
    ])
    
    fig.add_annotation(
        x=5,
        y=2.5,
        text="L",
        ax=0,
        ay=-40
    )
    
    fig.add_annotation(
        x=0,
        y=0,
        text="W",
        ax=-20,
        ay=-40
    )
    
    fig.update_annotations(dict(
        xref="x",
        yref="y",
        showarrow=True,
        arrowhead=7
    ))
    
    fig.update_layout(
        yaxis = dict(
            scaleanchor = "x",
            scaleratio = 1,
        ),
        showlegend = True,
        width=1000, 
        height=1000,
        autosize=False
    )
    
    fig.show()
    nd.clear_layout()

    Bastien

    in reply to: get layers used in a layout #6100
    bastien
    Member

    Thank you Ronald!

    df = nd.cfg.layer_table

    works perfectly for my use case

    Bastien

Viewing 5 posts - 1 through 5 (of 5 total)