1

So I have

import numpy as np
import matplotlib.pyplot as plt
plt.rc('text', usetex=True)
plt.rc('font', family='serif')
theta = np.linspace(0.000000000001,np.pi-0.000000000001,1024)
y = - 1 / ( ( theta - np.pi / 2 ) ** 4 - ( np.pi / 2 ) ** 4 )
y1 = y[:len(y)//2]
y2 = y[len(y)//2:]
theta1 = theta[:len(theta)//2]
theta2 = theta[len(theta)//2:]
plt.plot(theta1,y1,'r-')
#plt.plot(theta2,y2,'r-')
plt.xlabel(r'$\theta$')
plt.ylabel(r'$y$')
plt.yscale('log')
plt.xscale('log')
plt.show()

Which produces Plot1

Changing to the other plot

#plt.plot(theta1,y1,'r-')
plt.plot(theta2,y2,'r-')

gives Plot 2

Now I want the second plot to look similar to the first one. That is, the $\theta$ axis has to get finer approaching Pi as it does in the first plot approaching 0. In the first one I simply could use the plt.xscale('log') provided in matplotlib.pyplot. How would I do that for the second plot?

mujjiga
  • 16,186
  • 2
  • 33
  • 51
schoeni
  • 65
  • 9
  • Please provide the code used to produce the plots. Without it it is impossible to say what your problem is. – John Sloper Mar 20 '19 at 08:40
  • Is it though? I am given three functions $K(\theta)$ on an array $0<\theta<\pi$. I split the functions in two sides and want to illustrate the asymptotic for $\theta \to 0,\pi$. The built in plt.xscale('log') works for the asymptotic towards $0$. How to do that for the asymptotic towards $\pi$? – schoeni Mar 20 '19 at 08:52
  • Please have a look here https://stackoverflow.com/help/mcve. Take the time and write up the question as well as you can, and you will have it answered in minutes. – John Sloper Mar 20 '19 at 08:58
  • I understand your point. But the way the functions are created would certainly be too complicated to for this question. I try to reformulate to a more simple problem. – schoeni Mar 20 '19 at 09:01
  • Edit: I added a minimal example – schoeni Mar 20 '19 at 11:33
  • There is no predefined scale in matplotlib that would allow this, so you may need to create your custom scale. See e.g. [this question](https://stackoverflow.com/questions/43463431/custom-logarithmic-axis-scaling-in-matplotlib/43466610#43466610), or [this one](https://stackoverflow.com/questions/45306099/how-to-put-different-in-magnitude-values-at-same-distance-on-x-axis/45328150#45328150). – ImportanceOfBeingErnest Mar 20 '19 at 11:43
  • Thanks @ImportanceOfBeingErnest, I was able to recreate the code to suit my needs. ~answered (should I post my solution?) – schoeni Mar 21 '19 at 06:36
  • Since the question seems useful by itself, there are two options, I'd say: (1) If you think this case is sufficientely handled by any other question and answer you have used, you can vote to close as duplicate of it (or just state it here, so someone else will do that); (2) If you think this case is sufficiently different from any other question and answer, provide your own answer here. – ImportanceOfBeingErnest Mar 21 '19 at 11:29

0 Answers0