axes

matplotlib: custom projection for hemisphere/wedge

可紊 提交于 2019-12-09 18:58:27
问题 I'm looking at the custom projection example in the matplotlib gallery -- I'm trying to modify it to plot only the southern hemisphere. I have adjusted the necessary [-pi/2,pi/2] limits to [-pi/2,0]. Now I've been looking at: def _gen_axes_patch(self): """ Override this method to define the shape that is used for the background of the plot. It should be a subclass of Patch. In this case, it is a Circle (that may be warped by the axes transform into an ellipse). Any data and gridlines will be

matplotlib get all axes that a given figure contains to apply some settings

限于喜欢 提交于 2019-12-09 18:13:43
问题 I'm writing a function that modifies the axes size and position on a figure, but when comes twin axes it makes a problem: import matplotlib.pyplot as plt def fig_layout(fig, vspace = 0.3): # function to make space at the bottom for legend box and #+ other text input for ax in ~~~fig.axes~~~: # Here 'fig.axes' is not right, I need to find the exact syntax #+ I need to put box = ax.get_position() ax.set_position([box.x0, box.y0 + box.height * vspace, box.width, box.height * (1 - vspace)]) x =

How can I programmatically select a specific subplot in Matplotlib?

放肆的年华 提交于 2019-12-09 05:18:52
问题 So in a figure where three vertical subplots have been added with add_subplot, how can I select let's say the middle one? Right now I do this list comprehension: [r[0] for r in sorted([[ax, ax.get_geometry()[2]] for ax in self.figure.get_axes()], key=itemgetter(1))] where I can simply select the index I want, with the corresponding axes . Is there a more straightforward way of doing this? 回答1: From the matplotlib documentation: If the figure already has a subplot with key (args, kwargs) then

Bokeh Plot with equal axes

非 Y 不嫁゛ 提交于 2019-12-08 16:02:57
问题 Bokeh Plot with equal axes I created a Plot with the Python library Bokeh (see code). from bokeh.plotting import * figure() hold() rect([1,3], [1,1], [1,0.5], [1,0.5]) patch([0,0,4,4], [2,0,0,2], line_color="black", fill_color=None) show() How can I represent the squares (rectangle with the same width and height) with equal axes as in matplotlib with the command axis('equal') ? http://matplotlib.org/examples/pylab_examples/axis_equal_demo.html I see the option to change the width and height

Change number of x-axis ticks in seaborn plots

吃可爱长大的小学妹 提交于 2019-12-08 15:20:48
问题 I would like to be able to control the number of axis ticks on a seaborn plot in Python 3.5. I'm very accustomed to using R's ggplot, so I'm having some trouble with analogous functionality in Python. As a example, here is the kind of data I'm currently working with: test = pd.DataFrame() test["X"] = [1,2,3,1,2,3] test["Y"] = [1,5,3,7,2,4] test["Category"] = ["A", "A", "A", "B", "B", "B"] And I would like to do something like ggplot's facet_wrap() by doing: sns.set(style = "ticks", color

Why does my d3 chart's x-axis include the first of every month as a tick even though I set the tick interval to every 7 days?

拈花ヽ惹草 提交于 2019-12-08 09:08:55
问题 I am new to d3 but I have set the tick interval for my x-axis to every 7 days using d3.timeDay.every(7) . However when my graph is created, I also see a tick mark added for the first of every month. For example, my graph shows ticks at 10/1, 10/8, 10/15, 10/22, 10/29, and 11/1, even though 11/1 is not 7 days after 10/29. If I expand this range to include multiple months, I see a tick at the first of every month. I have included my code for this axis below. What might be causing the first of

Formatting a 3d bar plot in matplot lib

一世执手 提交于 2019-12-08 02:59:51
问题 I am working with this code example from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np data = np.array([ [0,1,0,2,0], [0,3,0,2,0], [6,1,1,7,0], [0,5,0,2,9], [0,1,0,4,0], [9,1,3,4,2], [0,0,2,1,3], ]) column_names = ['a','b','c','d','e'] row_names = ['Mon','Tue','Wed','Thu','Fri','Sat','Sun'] fig = plt.figure() ax = Axes3D(fig) lx= len(data[0]) # Work out matrix dimensions ly= len(data[:,0]) xpos = np.arange(0,lx,1) # Set up a mesh of positions ypos = np

matplotlib实战绘制各种图形

对着背影说爱祢 提交于 2019-12-08 02:48:49
plt.imshow(face_image.mean(axis=2),cmap='gray') 图片灰度处理 ¶ size = (m,n,3) 图片的一般形式就是这样的 rgb 0-255 jpg图片 166,255,89 0.0-1.0 png图片 0.1,0.2,0.6 灰度处理以后 rgb---->gray 166,255,89 ---> 190 0.1,0.2,0.6 -- > 0.4 size = (m,n) import scipy.misc as misc import numpy as np import pandas as pd from pandas import Series,DataFrame import matplotlib.pyplot as plt %matplotlib inline face_image = misc.face() plt.imshow(face_image) face_gray = misc.face(gray=True) plt.imshow(face_gray,cmap='gray') 三种方法 最大值法 平均值法 RGB权重法[0.299,0.587,0.114] plt.imshow(face_image.max(axis=2),cmap='gray') plt.imshow(face_image.mean(axis=2

Justify individual axis labels in bold using ggplot2

一曲冷凌霜 提交于 2019-12-07 03:18:20
问题 Question adapted from this question and solution: Highlighting individual axis labels in bold using ggplot2 I would like to selectively justify the horizontal axes labels depending on meeting a criteria. So borrowing from the above question and answer I've set up an example: require(ggplot2) require(dplyr) set.seed(36) xx<-data.frame(YEAR=rep(c("X", "Y"), each=20), CLONE=rep(c("A", "B", "C", "D", "E"), each=4, 2), TREAT=rep(c("T1", "T2", "T3", "C"), 10), VALUE=sample(c(1:10), 40, replace=T))

how to fix axes position by using set_position method in python matplotlib?

假装没事ソ 提交于 2019-12-06 20:19:14
问题 I think this is quite easy but I searched the internet and matplotlib users mailing list and not able to find an answer. ax2 is an inset axes within the "ax" axes in figure "fig", which I make by following here: http://matplotlib.sourceforge.net/examples/pylab_examples/axes_demo.html but now my problem is that I cannot fix the ax2 the exact position I want, it seems that draw() command change this: In [352]: ax2.set_position([0.125,0.63,0.25,0.25]) In [353]: ax2.get_position() Out[353]: Bbox