axes

Matplotlib coord. sys origin to top left

家住魔仙堡 提交于 2019-11-27 14:46:05
问题 How can I flip the origin of a matplotlib plot to be in the upper-left corner - as opposed to the default lower-left? I'm using matplotlib.pylab.plot to produce the plot (though if there is another plotting routine that is more flexible, please let me know). I'm looking for the equivalent of the matlab command: axis ij; Also, I've spent a couple hours surfing matplotlib help and google but haven't come up with an answer. Some info on where I could have looked up the answer would be helpful as

How to place the intercept of x and y axes at (0 , 0) and extend the x and y axes to the edge of the plot [duplicate]

▼魔方 西西 提交于 2019-11-27 13:55:59
问题 This question already has answers here : Set R plots x axis to show at y=0 (2 answers) Closed 9 months ago . Suppose I want to plot x^2 . I can use curve() as follows. curve(x^2, -5, 5) However, I would like the axes to go through (0, 0). I could do something as follows: curve(x^2, -5, 5, axes=FALSE) axis(1, pos=0) axis(2, pos=0) abline(h=0) abline(v=0) And I end up getting something like below, which looks OK. But the only gripe I have is that this way of plotting axes makes the actual axes

Matplotlib/pyplot: How to enforce axis range?

淺唱寂寞╮ 提交于 2019-11-27 12:39:28
问题 I would like to draw a standard 2D line graph with pylot, but force the axes' values to be between 0 and 600 on the x, and 10k and 20k on the y. Let me go with an example... import pylab as p p.title(save_file) p.axis([0.0,600.0,1000000.0,2000000.0]) #define keys and items elsewhere.. p.plot(keys,items) p.savefig(save_file, dpi=100) However, the axes still adjust to the size of the data. I'm interpreting the effect of p.axis to be setting what the max and min could be, not enforcing them to

Positioning axes labels

断了今生、忘了曾经 提交于 2019-11-27 11:41:36
How can I move the y axis label from the left to the right of the plot area and the x-axis label from below to above the plot area in the following graph? Thanks xleft<-c(1,2,2.5) xright<-c(2,2.5,2.75) ybottom<-c(1,2,2.5) ytop<-c(2,2.5,2.75) par(mar = c(15,15,2.75,2.75) + 0.1) plot(c(1,3),c(1,3),type="n",main="title",xlab="xlab-move me above plot",ylab="ylab-move me right of plot",axes=F,asp=1) axis(1,pos=1) axis(2,pos=1) rect(xleft,ybottom,xright,ytop,col=c("blue","red","green")) #Label position along axes x.label.position<-(xleft+xright)/2 y.label.position<-(ybottom+ytop)/2 #Labels x.label<

What are the differences between add_axes and add_subplot?

允我心安 提交于 2019-11-27 09:19:24
问题 In a previous answer it was recommended to me to use add_subplot instead of add_axes to show axes correctly, but searching the documentation I couldn't understand when and why I should use either one of these functions. Can anyone explain the differences? 回答1: Common grounds Both, add_axes and add_subplot add an axes to a figure. They both return a (subclass of a) matplotlib.axes.Axes object. However, the mechanism which is used to add the axes differs substantially. add_axes The calling

Reversed order after coord_flip in R

时光怂恿深爱的人放手 提交于 2019-11-27 02:06:02
问题 Data example from dbv: gender Sektion 1 m 5 2 m 5 3 w 3B 4 w 3B 5 w 3B 6 m 4 I have the following plot: Sekplot <- ggplot(dbv,aes(x=Sektion, fill=factor(gender), stat="bin", label = paste(round((..count..)/sum(..count..)*100), "%"))) Sekplot <- Sekplot + geom_bar(position="fill") Sekplot <- Sekplot + scale_y_continuous(labels = percent) Sekplot <- Sekplot + labs(title = "test") Sekplot <- Sekplot + scale_fill_discrete(name="test", breaks=c("m", "w", "k.A."), labels=c("m", "w", "k.A."))

scikit-image库-- 过滤区域最大值(三)

試著忘記壹切 提交于 2019-11-27 00:13:43
过滤区域最大值 import numpy as np import matplotlib . pyplot as plt % matplotlib inline from scipy . ndimage import gaussian_filter from skimage import data from skimage import img_as_float from skimage . morphology import reconstruction # Convert to float: Important for subtraction later which won't work with uint8 image = img_as_float ( data . coins ( ) ) image = gaussian_filter ( image , 1 ) seed = np . copy ( image ) seed [ 1 : - 1 , 1 : - 1 ] = image . max ( ) mask = image seed1 = np . copy ( image ) seed1 [ 1 : - 1 , 1 : - 1 ] = image . min ( ) erosion = reconstruction ( seed , mask , method =

Matlab: How to obtain all the axes handles in a figure handle?

房东的猫 提交于 2019-11-26 22:43:28
问题 How do I obtain all the axes handles in a figure handle? Given the figure handle hf , I found that get(hf, 'children') may return the handles of all axes. However, the Matlab Help suggests that it may return more than just the axes handles: Children of the figure . A vector containing the handles of all axes, user-interface objects displayed within the figure. You can change the order of the handles and thereby change the stacking of the objects on the display. Is there any way to obtain only

Strange error with matplotlib axes labels

你离开我真会死。 提交于 2019-11-26 20:18:51
问题 I'm very new to Python and programming in general, so apologies in advance if I'm missing something obvious. I'm trying to plot a graph and label the axes, but every time I try to label the y axis an exception is raised. I wrote the code below in a new script to make sure the problem wasn't coming from somewhere else in the module. I'm using Python 3.4. from numpy import * from matplotlib import * a = [1, 2, 3, 4, 5] b = [2, 3, 2, 3, 2] pyplot.plot(a, b) pylab.xlabel("Time") pylab.ylabel(

pyplot axes labels for subplots

不想你离开。 提交于 2019-11-26 19:15:37
I have the following plot: import matplotlib.pyplot as plt fig2 = plt.figure() ax3 = fig2.add_subplot(2,1,1) ax4 = fig2.add_subplot(2,1,2) ax4.loglog(x1, y1) ax3.loglog(x2, y2) ax3.set_ylabel('hello') I want to be able to create axes labels and titles not just for each of the two subplots, but also common labels that span both subplots. For example, since both plots have identical axes, I only need one set of x and y- axes labels. I do want different titles for each subplot though. I tried a few things but none of them worked right You can create a big subplot that covers the two subplots and