## [Matplotlib-users] Customizing yticks while log-scaled

 [Matplotlib-users] Customizing yticks while log-scaled From: Gökhan Sever - 2009-09-11 05:16:11 Attachments: Message as HTML ```Hello, A new plot and two questions: http://img16.imageshack.us/img16/1759/logbarchart.png 1-) How to get nicely formatted yticks while will represent my data range (in Ax10^5 fashion 10^x works perfect as a defaul however couldn't figure out how to do this with number times 10^x)? An interesting point is when log=True yticks has to be called with two arguments as in the code otherwise no ticks shown at all. 2-) This is about my ylabel, although I have mm^3 showing nicely for some reason the closing bracket tends to stay separately. How to fix this in the code? Thanks. ### BEGIN CODE http:/import numpy as np import matplotlib.pyplot as plt diameters = np.array([ 7, 10, 11, 12, 16, 21, 28, 35, 38, 51]) numbers = np.array([44, 24, 7, 8, 8, 12, 16, 3, 2, 1]) http:width = 1.0 volumes = 4./3*np.pi*(diameters/2)**3 plt.bar(diameters, volumes*numbers, width=width, align='edge', log=True) plt.axis(xmin=diameters.min()-2, xmax=diameters.max()+2, ymax =\ (volumes*numbers).max()+20000) plt.xlabel("Diameter (mm)", fontsize=16) plt.ylabel(r"Number of washers x Volumes (# \$mm^3\$)", fontsize=16) plt.xticks(diameters+width/2, diameters) #plt.yticks(volumes*numbers, volumes*numbers) #plt.yticks(np.arange(100, 2*10**5+100, 4*10**4), np.arange(100, 2*10**5+100, 4*10**4)) plt.figure() width = 0.4 plt.bar(range(len(diameters)), volumes*numbers, width=width, align='edge') plt.xlabel("Diameter (mm)", fontsize=16) plt.ylabel(r"Number of washers x Volumes (# \$mm^3\$)", fontsize=16) plt.xticks(np.arange(len(diameters))+width/2, diameters) plt.axis(xmin=-width/2, xmax=len(diameters)-width) #plt.yticks(volumes*numbers) plt.title("Distribution Lab - Question 2", fontsize=18) plt.show() ### CODE ENDS -- Gökhan ```

 [Matplotlib-users] Customizing yticks while log-scaled From: Gökhan Sever - 2009-09-11 05:16:11 Attachments: Message as HTML ```Hello, A new plot and two questions: http://img16.imageshack.us/img16/1759/logbarchart.png 1-) How to get nicely formatted yticks while will represent my data range (in Ax10^5 fashion 10^x works perfect as a defaul however couldn't figure out how to do this with number times 10^x)? An interesting point is when log=True yticks has to be called with two arguments as in the code otherwise no ticks shown at all. 2-) This is about my ylabel, although I have mm^3 showing nicely for some reason the closing bracket tends to stay separately. How to fix this in the code? Thanks. ### BEGIN CODE http:/import numpy as np import matplotlib.pyplot as plt diameters = np.array([ 7, 10, 11, 12, 16, 21, 28, 35, 38, 51]) numbers = np.array([44, 24, 7, 8, 8, 12, 16, 3, 2, 1]) http:width = 1.0 volumes = 4./3*np.pi*(diameters/2)**3 plt.bar(diameters, volumes*numbers, width=width, align='edge', log=True) plt.axis(xmin=diameters.min()-2, xmax=diameters.max()+2, ymax =\ (volumes*numbers).max()+20000) plt.xlabel("Diameter (mm)", fontsize=16) plt.ylabel(r"Number of washers x Volumes (# \$mm^3\$)", fontsize=16) plt.xticks(diameters+width/2, diameters) #plt.yticks(volumes*numbers, volumes*numbers) #plt.yticks(np.arange(100, 2*10**5+100, 4*10**4), np.arange(100, 2*10**5+100, 4*10**4)) plt.figure() width = 0.4 plt.bar(range(len(diameters)), volumes*numbers, width=width, align='edge') plt.xlabel("Diameter (mm)", fontsize=16) plt.ylabel(r"Number of washers x Volumes (# \$mm^3\$)", fontsize=16) plt.xticks(np.arange(len(diameters))+width/2, diameters) plt.axis(xmin=-width/2, xmax=len(diameters)-width) #plt.yticks(volumes*numbers) plt.title("Distribution Lab - Question 2", fontsize=18) plt.show() ### CODE ENDS -- Gökhan ```