Hi Jose, Have you tried to use the "DrawMolecules" from the "rdMolDraw2D.MolDraw2DSVG" class? I think this class has some other options that allow one to change the highlight colors while still keeping the alpha transparency. I did a test here with your code and it seems to provide the result you are looking for:
m = Chem.MolFromSmiles("O1CCCC1") # tetrahydrofuran highlight=[0] # oxygen matches = m.GetSubstructMatches(Chem.MolFromSmiles('CO')) print matches color_1 = {} color_2 = {} color_3 = {} radius = {} for i,j in zip(matches[0], matches[1]): color_1[i] = ColorConverter().to_rgb('lightgray') color_2[j] = ColorConverter().to_rgb('skyblue') tm = rdMolDraw2D.PrepareMolForDrawing(m) view = rdMolDraw2D.MolDraw2DSVG(660,350) option = view.drawOptions() option.padding=0.13 option.legendFontSize=18 view.DrawMolecules([tm], highlightAtoms=[highlight], highlightAtomColors=[color_2]) view.FinishDrawing() svg = view.GetDrawingText() with open('./example.svg', 'w') as f: f.write(svg) SVG(svg.replace('svg:', '')) I hope it works for you. All the best, Max Em qui, 20 de dez de 2018 às 14:33, Jose Manuel Gally < jose.manuel.ga...@gmail.com> escreveu: > Hi all, > > I am trying to highlight substructures found in a set of molecules. > > However, if I use a specific color in Draw.MolsToGridImage by defining the > highlightAtomColors parameter, I lose the transparency effect, so some > atoms can be hidden by the highlight. > > Is there a way to set the transparency level (alpha) with defined > highlightAtomColors? > > I could not find any relevant parameter in the documentation (alpha is > mentioned only once in the calcAtomGaussians docstring) or in this > mailing list. > > I also tried to set a value an additional value in the RGB code (i.e. > RGBa=(1, 0, 0, 0.5)), but it seems to be simply ignored. > > Please find attached a notebook with a very simple example. > > Am I missing something obvious? > > By default there seems to be some transparency applied when highlighting. > > Thank you for your help! > > Best regards, > Jose Manuel > _______________________________________________ > Rdkit-discuss mailing list > Rdkit-discuss@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/rdkit-discuss >
_______________________________________________ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss