Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add custom label? #923

Closed
diallobakary4 opened this issue Oct 5, 2020 · 4 comments
Closed

How to add custom label? #923

diallobakary4 opened this issue Oct 5, 2020 · 4 comments

Comments

@diallobakary4
Copy link

I am trying to add a custom label to a ligand without success.
Here is what I have tried so far.

view.add_label("488", labelType="resname", labelGrouping = 'residue')#, color ="black") 

The above does work but it's not custom.
None of the below does work for custom label!

view.add_label("488", labelText=["ZINC000050633276"], labelType="text")
view.add_label("488", labelText="ZINC000050633276", labelType="text")
view[0].add_representation('label', selection= "488", name= 'myLabel', labelType= 'text', labelText= ["ZINC000050633276"])

I am not sure what is the right syntax.
I am reading from a trajectory, so quite difficult to share.

nglview 2.7.7
ipywidgets; 7.5.1

@hainm
Copy link
Collaborator

hainm commented Oct 5, 2020

hi @diallobakary4, please try view.shape.add_label
#663

@hainm hainm closed this as completed Oct 21, 2020
@juliasubbotina
Copy link

@diallobakary4
Something like this should work:

    view.add_representation(repr_type="label", name = "label", showBackground = True, labelType = "atomname", color = "black", 
                     sele = bSel,   xOffset = 0.5 , zOffset =5 )

Full description of options can be found here.
The result will look like this:

eq_ua_chl1_cgMap_0

@hainm
Copy link
Collaborator

hainm commented Nov 14, 2022

Thanks @juliasubbotina

@juliasubbotina
Copy link

@hainm @arose
Apparently as @diallobakary4 has mentioned, the labelType="text" is not working. I have the same issue (#1047) Changing atom names is a workaround, but not always safe/useful.
Maybe somebody can take a deeper look into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants