axes

How to get a matplotlib Axes instance to plot to?

泄露秘密 提交于 2019-11-26 16:07:03
问题 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

How do I edit the axes of an image in MATLAB to reverse the direction?

寵の児 提交于 2019-11-26 14:08:31
问题 I would like to edit the axes in my series of images being displayed. This is what my image looks like: As you can see, it ranges from 0 to about 500 from top to bottom. Can I invert that? Plus, I want to mirror the image being shown, so that it starts from left to right... or, if it's possible, to let the axes show from right to left. 回答1: To reverse an axis, you can set the 'XDir' or 'YDir' property of the current axes to 'reverse' : set(gca,'XDir','reverse'); %# This flips the x axis Keep

pyplot axes labels for subplots

末鹿安然 提交于 2019-11-26 08:57:36
问题 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

Force R to stop plotting abbreviated axis labels - e.g. 1e+00 in ggplot2

亡梦爱人 提交于 2019-11-26 08:06:51
问题 In ggplot2 how can I stop axis labels being abbreviated - e.g. 1e+00, 1e+01 along the x axis once plotted? Ideally, I want to force R to display the actual values which in this case would be 1,10 . Any help much appreciated. 回答1: I think you are looking for this: require(ggplot2) df <- data.frame(x=seq(1, 1e9, length.out=100), y=sample(100)) # displays x-axis in scientific notation p <- ggplot(data = df, aes(x=x, y=y)) + geom_line() + geom_point() p # displays as you require require(scales) p

Set scientific notation with fixed exponent and significant digits for multiple subplots

夙愿已清 提交于 2019-11-26 07:49:42
问题 I am trying to fix the axes to scientific notation of two different sets of data where one is [1-9]x1e-3 and the other is [1-9]x1e-4. I would like to set both axes to be 10^-4 and have the one digits after decimal (e.g. %.1e). Here is a simple version that I have tried to play around with: I would like the numbers on the axes to be at least 1 and I want both powers to be the same. import numpy as np import matplotlib.pyplot as plt x = np.linspace(1,9,9) y1 = x*10**(-4) y2 = x*10**(-3) fig, ax

Force the origin to start at 0

删除回忆录丶 提交于 2019-11-25 23:46:35
问题 How can I set the origin / interception of the y-axis and x-axis in ggplot2? The line of the x-axis should be exactly at y=Z . With Z=0 or another given value. 回答1: xlim and ylim don't cut it here. You need to use expand_limits , scale_x_continuous , and scale_y_continuous . Try: df <- data.frame(x = 1:5, y = 1:5) p <- ggplot(df, aes(x, y)) + geom_point() p <- p + expand_limits(x = 0, y = 0) p # not what you are looking for p + scale_x_continuous(expand = c(0, 0)) + scale_y_continuous(expand