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

x-labels behave weirdly in semilogx plot. #33

Open
Yakonshus opened this issue May 22, 2019 · 2 comments
Open

x-labels behave weirdly in semilogx plot. #33

Yakonshus opened this issue May 22, 2019 · 2 comments

Comments

@Yakonshus
Copy link

Hi! Thanks for the tool, I'm not so skilled in python and I need to plot something so devious as a logx plot with the data points presented as x time after stimulation, a zero point. I have three problems

In the plot, the beginning and end of the first xlim is always ticked ( 6 x 10^0 and 2 x 10^1) - How do I remove this?

I want to label the ticks that corresponds to my x values. In the log scale, it only wants to label clean log10 values, and not intermediates such as 500, 1500 etc... The way I do it now, the distance between the major ticks is not the same either. That looks weird in a log plot.

I circumvented the x-value zero by saying that x value of the stimulation time is 10, but in the plot I would like to make a custom tick that says this point is 0, or stimulation time.

x = [10, 500, 1500, 15000, 150000]

fig = plt.figure(figsize=(6,4))
bax = brokenaxes(xlims=((6,20),(300,400000)), wspace=.08, xscale='log')

bax.semilogx(x, wt_master, 'o', ms=8, label='ChR2-wt')
bax.semilogx(x, dc_master, 'x', ms=10, label='ChR2-XXL')

bax.vlines(10,-1,3,color = 'k', linestyles = 'dashed', alpha=0.8)

bax.legend(loc='upper left')
bax.grid(axis='both', which='major', ls='-')
bax.grid(axis='both', which='minor', ls='--', alpha=0.3)
bax.set_ylabel('Normalised Membrane Current')
bax.set_xlabel('\nTime after peak current [ms]')
bax.set_ylim(0,2)

bax.axs[0].set_xticks([0])
bax.axs[1].set_xticks([500,1500,15000,150000])
plt.show()

Udklip

@bendichter
Copy link
Owner

could you provide the data?

I think you want to work with bax.axs[1].set_xtickslabels

@Yakonshus
Copy link
Author

Thanks for the quick reply!

The yellow crosses have the y-values:
dc_master = [1, 0.97191375, 1.1808187, 1.3289762, 1.4749643 ]

If I try set_xtickslabels I get

AttributeError: 'AxesSubplot' object has no attribute 'set_xtickslabels'

Though right now I just moved to plotting it without log scale and just define my own positions with matplotlib so I don't have to break.

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

2 participants