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

ax.text() is bugging when using a posy <0 #50

Open
ijunier opened this issue Jun 18, 2020 · 3 comments
Open

ax.text() is bugging when using a posy <0 #50

ijunier opened this issue Jun 18, 2020 · 3 comments
Labels
bug Something isn't working OSX

Comments

@ijunier
Copy link
Contributor

ijunier commented Jun 18, 2020

  • It works with posy > 0
  • OSX bug?

Here is the the code which makes the code bug (it works with ax.text(-0.5,0.25,"Ter",color='blue')):

import numpy as np

from matplotlib import rc
rc('font', **{'family': 'sans-serif', 'sans-serif':['Helvetica']})
rc('text', usetex=True)

import matplotlib.pyplot as plt

from matplotlib import colors

from circhic import datasets
from circhic import CircHiCFigure
from circhic.utils import generate_circular_map
from circhic.utils import generate_borders

from iced.normalization import ICE_normalization

data = datasets.load_ecoli()
counts = data["counts"]
lengths = data["lengths"]
counts, bias = ICE_normalization(counts, output_bias=True)

granularity = 0.5
resolution = 9897

fig = plt.figure(figsize=(6, 6))


inner_radius, outer_radius = 0.15, 0.95
inner_gdis, outer_gdis = 1200000, 800000

chrom_lengths = lengths * resolution
circhicfig = CircHiCFigure(chrom_lengths, figure=fig)
m, ax = circhicfig.plot_hic(counts, granularity=granularity, resolution = resolution,
                            outer_radius=outer_radius, inner_radius=inner_radius,
                            inner_gdis=inner_gdis, outer_gdis=outer_gdis,
                            vmin=7, cmap="bone_r",border_thickness=0.005)

rax = circhicfig._create_subplot(outer_radius=outer_radius)
rax.set_rlim((-inner_gdis, outer_gdis))

rax.spines["polar"].set_linewidth(0)
rax.spines["inner"].set_linewidth(0)
rax.set_thetagrids([], labels=[""])
rax.set_rgrids([])

circhicfig._plot_raxis(outer_radius, inner_radius, outer_gdis, inner_gdis)

if True:
    ticklabels = [
            "%d~kb" % (i / 1000) for i in np.arange(0, chrom_lengths[0], 50*resolution)[:-1]]
    tickpositions=np.arange(0, chrom_lengths[0], 50*resolution)[:-1]
    print(tickpositions)
    print(ticklabels)    
    #ticklabels[0] = "ORI"
    ax = circhicfig.set_genomic_ticklabels(
        tickpositions=tickpositions,
        ticklabels=ticklabels,
        outer_radius=0.98)
    ax.tick_params(colors="0.3")


inner_radius, outer_radius = 0.62, 0.67
circhicfig.plot_bands(np.array([int(0.26*chrom_lengths[0])]), np.array([int(0.41*chrom_lengths[0])]), colors=('blue',),
                      inner_radius=inner_radius, outer_radius=outer_radius)


ax.text(-0.5,-0.25,"Ter",color='blue')

circhicfig.figure.savefig("figures/test_coli.pdf")
@ijunier ijunier added the bug Something isn't working label Jun 18, 2020
@NelleV
Copy link
Contributor

NelleV commented Jun 22, 2020

I'll test this on thursday or friday, when I have access to OSX

@NelleV NelleV added the OSX label Jun 22, 2020
@NelleV
Copy link
Contributor

NelleV commented Jul 1, 2020

On my version of Matplotlib, that leads to the following message: "posx and posy should be finite values"

Seems somewhat related to matplotlib/matplotlib#11202

@NelleV
Copy link
Contributor

NelleV commented Jul 1, 2020

I think that the issue is that you are trying to add text outside of the scope of the figure, which is weird for this kind of polar plot (it's in the empty donut hole). The fact that matplotlib doesn't raise an error but only raises a warning makes it very hard to debug… in order to exactly check what is going on, I would have to install a development version of Matplotlib and edit the code in order to add a breakpoint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working OSX
Projects
None yet
Development

No branches or pull requests

2 participants