Forum Replies Created
-
AuthorPosts
-
21 October 2020 at 17:30 in reply to: type error when using sympy – fixed by converting to float #6279
bastien
MemberDear 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…
bastien
MemberGreat!
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
bastien
MemberDear 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
bastien
MemberHi 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
bastien
MemberThank you Ronald!
df = nd.cfg.layer_table
works perfectly for my use case
Bastien
-
AuthorPosts