axes

How do I swap tensor's axes in TensorFlow?

孤者浪人 提交于 2019-11-28 06:53:59
I have a tensor of shape (30, 116, 10) , and I want to swap the first two dimensions, so that I have a tensor of shape (116, 30, 10) I saw that numpy as such a function implemented ( np.swapaxes ) and I searched for something similar in tensorflow but I found nothing. Do you have any idea? keveman tf.transpose provides the same functionality as np.swapaxes , although in a more generalized form. In your case, you can do tf.transpose(orig_tensor, [1, 0, 2]) which would be equivalent to np.swapaxes(orig_np_array, 0, 1) . 来源: https://stackoverflow.com/questions/38212205/how-do-i-swap-tensors-axes

How to get a matplotlib Axes instance to plot to?

断了今生、忘了曾经 提交于 2019-11-28 06:08:53
I need to make a candlestick chart (something like this) using some stock data. For this I want to use the function matplotlib.finance.candlestick() . To this function I need to supply quotes and " an Axes instance to plot to ". I created some sample quotes as follows: quotes = [(1, 5, 6, 7, 4), (2, 6, 9, 9, 6), (3, 9, 8, 10, 8), (4, 8, 8, 9, 8), (5, 8, 11, 13, 7)] I now also need an Axes instance though, at which I am a bit lost. I created plots before using matplotlib.pyplot. I think I now need to do something with matplotlib.axes though, but I am unsure what exactly. Could anybody help me

Correct placement of colorbar relative to geo axes (cartopy)

有些话、适合烂在心里 提交于 2019-11-27 23:21:26
问题 Using Cartopy, I would like to have full control of where my colorbar goes. Usually I do this by getting the current axes position as basis and then create new axes for the colorbar. This works well for standard matplotlib axes but not when using Cartopy and geo_axes, because this will distort the axes. So, my question is: how do I get the exact position of my geo_axes? Here is a code example based on the Cartopy docs http://scitools.org.uk/cartopy/docs/latest/matplotlib/advanced_plotting

MATLAB how to get mouse click coordinates

霸气de小男生 提交于 2019-11-27 23:13:58
I have made my GUI using GUIDE. I have an axes (tag=axes1). An image is displayed in the axes. When i click on the image(inside axes) I need to get the coordinates. I get the coordinate values when image is not added to axes.But image is displayed in axes do no obtain the axes. How to get the coordinates? Let's assume that you've plotted the image with handle imageHandle that: imageHandle = imshow(imageObj); You should assign the ButtonDownFcn to the image handle not the axes handle that: set(imageHandle,'ButtonDownFcn',@ImageClickCallback); and get the mouse coordinates from this function as

What is the correct way to replace matplotlib tick labels with computed values?

◇◆丶佛笑我妖孽 提交于 2019-11-27 21:24:18
问题 I have a figure with a log axis and I would like to relabel the axis ticks with logs of the values, rather than the values themselves The way I've accomplished this is with plt.axes().set_xticklabels([math.log10(x) for x in plt.axes().get_xticks()]) but I wonder if there isn't a less convoluted way to do this. What is the correct idiom for systematically relabeling ticks on matplotlib plots with values computed from the original tick values? 回答1: Look into the Formatter classes. Unless you

Axes class - set explicitly size (width/height) of axes in given units

China☆狼群 提交于 2019-11-27 19:11:48
I want to to create a figure using matplotlib where I can explicitly specify the size of the axes, i.e. I want to set the width and height of the axes bbox. I have looked around all over and I cannot find a solution for this. What I typically find is how to adjust the size of the complete Figure (including ticks and labels), for example using fig, ax = plt.subplots(figsize=(w, h)) This is very important for me as I want to have a 1:1 scale of the axes, i.e. 1 unit in paper is equal to 1 unit in reality. For example, if xrange is 0 to 10 with major tick = 1 and x axis is 10cm, then 1 major tick

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

ぃ、小莉子 提交于 2019-11-27 18:44:36
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 the axes handle in the figure handle? Or how do I know if the handle returned by get(hf, 'children')

Moving x or y axis together with tick labels to the middle of a single ggplot (no facets)

放肆的年华 提交于 2019-11-27 16:48:08
问题 I made the following plot in Excel: But then I thought I would make it prettier by using ggplot. I got this far: If you're curious, the data is based on my answer here, although it doesn't really matter. The plot is a standard ggplot2 construct with some prettification, and the thick line for the x-axis through the middle is achieved with p + geom_hline(aes(yintercept=0)) ( p is the ggplot object). I feel that the axis configuration in the Excel plot is better. It emphasizes the 0 line

Crossing axis and labels in matlab

戏子无情 提交于 2019-11-27 16:45:26
问题 I just can't find it. How to set up axis and labels in matlab so they cross at zero point, with the labels just below the axis not on left/bottom of the plot ? If I didn't make myself clear - I just want the plot to look like like we all used to draw it when in school. Axes crossing, 4 quadrants, labels right below axis, curve ... as it goes. Anyone knows how to set it up ? 回答1: You should check out two submissions on The MathWorks File Exchange: PlotAxisAtOrigin by Shanrong Zhang axescenter

Custom logarithmic axis scaling in matplotlib

六月ゝ 毕业季﹏ 提交于 2019-11-27 16:17:55
I'm trying to scale the x axis of a plot with math.log(1+x) instead of the usual 'log' scale option, and I've looked over some of the custom scaling examples but I can't get mine to work! Here's my MWE: import matplotlib.pyplot as plt import numpy as np import math from matplotlib.ticker import FormatStrFormatter from matplotlib import scale as mscale from matplotlib import transforms as mtransforms class CustomScale(mscale.ScaleBase): name = 'custom' def __init__(self, axis, **kwargs): mscale.ScaleBase.__init__(self) self.thresh = None #thresh def get_transform(self): return self