-
-
Notifications
You must be signed in to change notification settings - Fork 28
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
Questions about legend and colorbar settings #3
Comments
Thank you for your questions. Those are very good questions. row_ha = HeatmapAnnotation(label=anno_label(df.AB, merge=True,rotation=15),
AB=anno_simple(df.AB,add_text=True),axis=1,
CD=anno_simple(df.CD,add_text=True,colors={'C':'red','D':'green','G':'blue'},
legend_kws={'frameon':False}),
Exp=anno_boxplot(df_box, cmap='turbo'),
Scatter=anno_scatterplot(df_scatter), TMB_bar=anno_barplot(df_bar),
) In the above example, I added legend_kws in (2). Similarly, you also can add parameters I hope these answers will be helpful to you. Thanks. |
Thanks @DingWB for your quick response. A few more questions: Regarding (2), I added In (3), I meant setting visibility of the axes spines to False. For instance, in the provided jupyter notebook example second cell i.e. "2. A quick example" if you change |
Two more quick questions and I would really appreciate your suggestion:
|
|
For horizontal legend, I haven't implemented it now. But you can plot the legend separately , just like what I shown in the example.ipynb, but using legend_kws "horizonal". For axes spine, could you please give me an example? How to reproduce it? It would be better if you can provide your code. |
Here's an example:
|
I see. I understand what you mean now. You want to remove the border of the heatmap. To simplify, you can add one line of code: I also modified my code and set 'ax_heatmap.set_axis_off()' on default when BTW, in my example, in plt.rcParams['figure.dpi'] = 100
plt.rcParams['savefig.dpi']=300 When you save it as a pdf file, does it looks normal in the pdf file? If it still doesn't work, you can also change the parameter |
If the color bar overlaps with each other in the figure legend area, you could increase the gap between legends by adding a parameter |
The issue is not because of the overlap. It's because when you use horizontal mode it doesn't rotate it. Here is an example:
Changing its aspect doesn't work either. Meaning colorbar width cannot be changed at all. Perhaps it's because as you mentioned you haven't implemented this feature yet. It also seems when you set some attributes of |
Yes, I haven't implemented the horizontal figure legend. This is why I suggested you plot the figure legend separately using legend_kws={"color_text": False} #if color_test is False, then 'black' would be the default
# Or if you want to use another custom color (such as blue), instead of black, please set
legend_kws={'color_text':False,'labelcolor':'blue'} Or would you happen to have any suggestions about how to make the By the way, do you want to contribute to this package? if you want, you can help me implement the horizontal figure legend. |
I see, got it. I didn't know there is I'm trying to understand the code a bit better which may take a while but I'd be happy to contribute to this package later. There are also a couple of things that I haven't found a solution. For example,
There are a couple more, I'll try to write them in this issue later. |
That is an excellent question. Please try: anno_simple(df_box.Gene1,vmin=0,vmax=1,legend_kws={'vmin':0,'vmax':1}),
|
Since you have already familiar with almost all of the parameters. Could you please help me with the documentation if you want to contribute when you have time later? @faridrashidi |
Sure, wherever I found something is missing I'll update it. Regarding my question in #3 (comment), suppose you have the following data. When I plot it, it is treated as values are continues while the values are only 0, 1 and 2. Is there any trick to make the heatmap discrete?
Also, I still don't have a solution for this: |
Maybe you can try: data = pd.DataFrame(
np.random.randint(0, 3, (5, 5)),
columns=["a", "b", "c", "d", "e"],
index=["c1", "c2", "c3", "c4", "c5"],
)
plt.figure()
row_ha = HeatmapAnnotation(df=data,plot=True,plot_legend=False)
plt.show() |
Yeah, that's an option but I thought maybe there is a solution that PyComplexHeatmap automatically detects discrete/object values and creates a discrete legend as well. Bwt, it would be nice to have a function that returns example dataset that you often use, something similar to seaborn see https://seaborn.pydata.org/generated/seaborn.load_dataset.html |
Is there any way to change the title of color bar position from its right to left? Because the ticklabels are in right so might look nicer if the title can be placed to the left. |
For the width of the legend #3 (comment), the width of the legend is hard coding to be 4.5mm. Is it necessary to make the width into a parameter? The label side of the colormap legend is also hard-coded to be the same as # for example, cm is the output of ClusterMapPlotter.
for ax in cm.legend_axes[0].figure.axes: #cm.ax.figure.axes
if ax.get_ylabel() == "Exp":
#ax.yaxis.set_ticks_position('left') #you can also change the tick to the left
ax.yaxis.set_label_position('left') |
@faridrashidi I have already added a parameter |
Wow, that's so nice! I followed your suggestion for annotationg rows or columns with texts in #3 (comment) and came up with the following example. You may add it to the examples.ipynb if you'd like to.
|
Thank you, this is an excellent example. I have modified it and added it to the example.ipynb and documentation (see anno_label section in https://dingwb.github.io/PyComplexHeatmap/build/html/notebooks/examples.html#anno_label:). |
Dear Wubin,
Thank you very much for creating this incredibly useful package. I have three questions regarding some settings.
frameon
toFalse
for categorical legends?colorbar
attributes such asaspect
ororientation
?row_split
orcol_split
is not set to None axes are visible, how one in this case can turn them off?Thank you in advance for your time.
The text was updated successfully, but these errors were encountered: