Skip to main content

Questions tagged [yaxis]

For plotting questions related to adjusting the y-axis.

Filter by
Sorted by
Tagged with
915 votes
12 answers
2.5m views

How do I set the figure title and axes labels font size?

I am creating a figure in Matplotlib like this: from matplotlib import pyplot as plt fig = plt.figure() plt.plot(data) fig.suptitle('test title') plt.xlabel('xlabel') plt.ylabel('ylabel') fig.savefig(...
vasek1's user avatar
  • 13.9k
698 votes
10 answers
1.8m views

How to set the axis limits

I need help with setting the limits of y-axis on matplotlib. Here is the code that I tried, unsuccessfully. import matplotlib.pyplot as plt plt.figure(1, figsize = (8.5,11)) plt.suptitle('plot title')...
Curious2learn's user avatar
149 votes
6 answers
272k views

How can I plot with 2 different y-axes?

I would like superimpose two scatter plots in R so that each set of points has its own (different) y-axis (i.e., in positions 2 and 4 on the figure) but the points appear superimposed on the same ...
DQdlM's user avatar
  • 10.1k
95 votes
4 answers
191k views

Barchart with vertical ytick labels

I'm using matplotlib to generate a (vertical) barchart. The problem is my labels are rather long. Is there any way to display them vertically, either in the bar or above it or below it?
phihag's user avatar
  • 285k
82 votes
3 answers
78k views

seaborn heatmap y-axis reverse order

Have a look at this heatmap found in the seaborn heatmap documentation. Right now the y-axis starts with 9 at the bottom, and ends with 0 on top. Is there a way to turn this around, i.e. start with 0 ...
john kals's user avatar
  • 851
40 votes
5 answers
102k views

Setting the same axis limits for all subplots

This problem seems simple enough, but I can't find a pythonic way to solve it. I have several (four) subplots that are supposed to have the same xlim and ylim. Iterating over all subplots à la f, ...
MrArsGravis's user avatar
36 votes
5 answers
88k views

Fixing x axis scale and autoscale y axis

I would like to plot only part of the array, fixing the x part, but letting the y part autoscale. I tried as shown below, but it does not work. Any suggestions? import numpy as np import matplotlib....
Pygmalion's user avatar
  • 849
32 votes
3 answers
26k views

yaxis range display using absolute values rather than offset values

I have the following range of numpy data (deltas of usec timestamps): array([ 4.312, 4.317, 4.316, 4.32 , 4.316, 4.316, 4.319, 4.317, 4.317, 4.316, 4.318, 4.316, 4.318, 4.316, 4.318, ...
David Poole's user avatar
  • 3,472
32 votes
2 answers
44k views

How to plot on secondary y-Axis with plotly express

How do I utilize plotly.express to plot multiple lines on two yaxis out of one Pandas dataframe? I find this very useful to plot all columns containing a specific substring: fig = px.line(df, y=df....
derflo's user avatar
  • 1,071
26 votes
6 answers
112k views

Make axis ticks labels bold when using usetex=True

I want to have bold labels on my axis, so I can use the plot for publication. I also need to have the label of the lines in the legend plotted in bold. So far I can set the axis labels and the legend ...
red_tiger's user avatar
  • 1,442
24 votes
2 answers
73k views

Combining Bar and Line chart (double axis) in ggplot2

I have double-y-axis chart made in Excel. In Excel it requires only basic skills. What I'd like to do is to replicate this chart using the ggplot2 library in R. I have already done this, but I need ...
AK47's user avatar
  • 1,328
13 votes
4 answers
7k views

How to plot without extending axis limits

I'm trying to draw on an existing axis without extending or modifying its limits. For example: import numpy as np import matplotlib.pyplot as plt xy = np.random.randn(100, 2) plt.scatter(xy[:,0], ...
shadowtalker's user avatar
  • 13.5k
13 votes
2 answers
14k views

Aligning y-ticks to the left

I have tick labels of variable length, and I want to align them to the left (i.e. to have a space between the shorter ones and the y axis). Is there any reasonable way to do this? Using horizontal ...
tktk's user avatar
  • 11.7k
13 votes
1 answer
5k views

Adding second Y axis on ggplotly

I have created the following dataframe object and graph using plotly and ggplot library(ggplot2) library(plotly) rdate <- function(x, min = paste0(format(Sys.Date(), '%Y'), '-01-01')...
Raghavan vmvs's user avatar
11 votes
2 answers
23k views

Set ylim on subplot secondary y-axis

I want to plot the data in subplots using secondary axes. I can set the ylim but it affects only the secondary y-axis (on the right side). I can't find a way to control the ylim on the primary y-axis (...
user3508369's user avatar
11 votes
1 answer
7k views

formatting secondary y axis in pandas

I am plotting a pandas DataFrame with several columns as below: fig, ax = py.subplots(figsize=(11.7, 8.3)) df.plot(ax=ax, secondary_y=[A]) I can format the primary yaxis with a command as below: ax....
dreamwalker's user avatar
  • 1,733
9 votes
2 answers
3k views

How to reverse secondary continuous_y_axis in ggplot2

I have a dataset I would like to graph with two Y-axes. The would like to reverse the secondary Y-axis so that it runs -60 to -40. The primary Y-axis should run 300-550. I cannot figure out how to ...
Christopher's user avatar
8 votes
6 answers
25k views

How to hide y axis?

I plot a horizontal boxplot in MATLAB -- boxplot(y, group,'orientation','horizontal'), and then hide the y-axis using set(gca,'box','off','ycolor','w'). It looks fine on the screen - only the bottom ...
Rory's user avatar
  • 341
8 votes
1 answer
13k views

Octave: Add secondary y axis to existing plot

I am using Octave 4.2.1 portable under Win 10. I have several plots in a single chart, with a single y axis, each one created with a plot(...) sentence. I want to add a plot in a secondary y axis to ...
sancho.s ReinstateMonicaCellio's user avatar
7 votes
2 answers
12k views

ggplot2 (Barplot + LinePlot) - Dual Y axis

I am having a really hard time recreating an excel example with ggplot2. I have tried numerous examples but for some reason I cannot reach my desired result. Can someone please have a look at my ...
Cosmin's user avatar
  • 585
7 votes
2 answers
9k views

ggplot: Boxplot by several categorical variables

I am trying to plot several boxplots in one chart using ggplot2. I have 1 continuous variable and several factors. I would like to have a single Y axis and each pair of boxplots to have their own x ...
user2053921's user avatar
7 votes
1 answer
3k views

Matplotlib: imshow with second y axis

I'm trying to plot a two-dimensional array in matplotlib using imshow(), and overlay it with a scatterplot on a second y axis. oneDim = np.array([0.5,1,2.5,3.7]) twoDim = np.random.rand(8,4) plt....
Chris's user avatar
  • 731
6 votes
2 answers
8k views

Echarts3.0 display percent on y-axis in stacked bar chart

Using Echarts3.0 in Vuejs2.0 component, I am trying to assign percent on y-axis in a stacked bar chart. I tried boundaryGap, splitnumber, etc, but none of them worked. But i cannot achieve it, ...
WonderHeart's user avatar
6 votes
1 answer
13k views

R | ggplot2 | (remove tick marks + remove panel border) but keep axis lines

novice user here so please be kind and gentle! :) I am dealing with the following dataset and R script: #Create pvalue ranges pvalue <- c(".000 - .005",".005 - .010",".010 - .015",".015 - .020","....
James F's user avatar
  • 65
5 votes
1 answer
20k views

Changing the imshow origin

I have a table of data with 3 columns, which I want to plot the third column in terms of the first two in a colorful 2D plot. For example for the following table i.e. 4.0 4.0 0.313660827978 4.0 5.0 ...
Rotail's user avatar
  • 1,061
5 votes
1 answer
14k views

Recharts Y-Axis interval issue

I am using Recharts Library for the graph in the ReactJS. There is one strange issue of setting intervals for the Y-Axis. There are few options available "preserveStart" | "preserveEnd&...
Sunny Vaghadia's user avatar
5 votes
1 answer
221 views

Two plot side by side using base R plots, with shared titel and shared x-axis label

I'm trying to plot two plots side by side using base R. I'd like them to share the title and the x-axis and y-axis label. However, the range of the plots is different, so I want to keep the number of ...
Linus's user avatar
  • 141
5 votes
3 answers
268 views

Highcharts Plot Reciprocal Values For Column Height

I am trying to plot a categorical multi axis column chart of rankings. The number 1 ranking should be the tallest column and lowest ranking the shortest. Essentially I would like the height of the ...
Bryan's user avatar
  • 17.4k
5 votes
1 answer
1k views

Error "NAs are not allowed in subscripted assignments" while using Squash_axis in ggplot2, with dataset without NA-values

I want to skip part of my y-axis for a dataset with most values between -10 and 100, and then a few at 400 again. So I want to squeeze this empty area. I already am using facet grid in my plot for 3 ...
Marretje Adriaanse's user avatar
5 votes
2 answers
11k views

Multiple y axis for bar plot and line graph using ggplot

I have some transpiration data from an experiment that I would like to show as a time series on a line graph using R. I also have some precipitation data which I would like to show on the same graph ...
A.Benson's user avatar
  • 465
5 votes
3 answers
4k views

Chart.js How to change y axis title position

I am working with the chart.js library to create a graph and I am almost done. One of the last things is to position the title of the yAxis to the top just under the legend. I currently have ...
Tajlang's user avatar
  • 51
4 votes
1 answer
7k views

How to add more Y-axes to MSChart with different scale at left or right side

I want to add 3 Y-axes for the chart with different scales. I want to get one x axis and different y axis. I did it like below code but I want to show one y axis like in the 2nd image that I attached....
SNP's user avatar
  • 51
4 votes
2 answers
20k views

Y-break with scale change in R

I am still new to R. I agreed to help a friend replot his graphs however one of his plot designs is proving quite hard to reproduce. This is because he inserted a Y-axis break followed by a scale ...
Scientist's user avatar
  • 1,249
4 votes
1 answer
6k views

ggplot yaxis with arrow [duplicate]

Is there anyone who knows how to change the y-axis horizontally and add the arrow? I want to make graph like this. This is the code that I used for making this graph. ggplot(plot, aes(x=Worried....
Sehee Yang's user avatar
4 votes
2 answers
10k views

How to set limit range

Why doesn't matplotlib.pyplot.xlim() method work in the below example? import matplotlib.pyplot as plt l = [0,0.2,0.4,0.6,0.8,1.0] plt.plot(l,l) plt.xlim = (-10,10) plt.show()
Denis Kuzin's user avatar
4 votes
3 answers
7k views

ggplot2: How to end y-axis on a tick mark?

I am making several different plots with different axis ranges, so this question does not apply to only the code I am showing here. I tried modifying the breaks and intervals of tick marks, but for ...
Jon's user avatar
  • 601
4 votes
2 answers
10k views

Rotating the y-axis label

I am trying to rotate the title of the Y axis so it is horizontal. I do not want the tick labels horizontal just the title of the Y axis. I have to use subplots as I am making multiple plots at once....
jms1980's user avatar
  • 1,065
4 votes
1 answer
5k views

How to change the limits from scale_y_continuous depending on the plot in R?

I want to draw boxplots with the number of observations on top. The problem is that depending on the information and the outliers, the y-axis changes. For that reason, I want to change the limits of ...
emr2's user avatar
  • 1,660
4 votes
4 answers
8k views

Subplots with two y axes (each) - plotly and python/pandas

Are there guidelines on how to set up secondary Y-axes in python for plotly? I am assinging axis style through an iterative loop, as follows: all_plots = ['plot1','plot2'...'plot20'] fig = tools....
Andreuccio's user avatar
  • 1,073
4 votes
1 answer
7k views

Python Seaborn FacetGrid different y-axis

I'm using sns.FacetGrid to plot 10 subplots. I'd like to flex the y-axis to be different for each subplot. At the moment it automatically uses the same for all subplots. Would it be possible to ...
Dany's user avatar
  • 43
4 votes
1 answer
124 views

ggplot2 facet_grid create panels on the y-axis

I have similar data like the following example: dat1 <- data.frame(group=c("a", "a","a", "a","a","a","b","b","b","b","b", "b", "b","b","b","c","c","c","c","c","c"), subgroup=c(...
Indigofera suffruticosa's user avatar
4 votes
1 answer
273 views

How to extract y axis labels from boxplot in R?

How to extract the y-axis labels from the boxplot in R? Example, bxp = boxplot(1:100) The y-axis labels are 0, 20, 40, 60, 80, 100. I wonder how to extract this programmingly?
WCMC's user avatar
  • 1,731
4 votes
2 answers
64 views

Plot with 2 y-axes : reversing the first one but not the second

First, I plotted a line chart of Depth in function of Age. Then, I added a second y-axis : Sedimentation Rate. The problem is that my first y-axis (Depth) should be reversed, going from 0 (top) to 310 ...
Mlp's user avatar
  • 41
4 votes
1 answer
523 views

Plotting a swarmplot on a violinplot changes the ylim and truncates the violins

import seaborn as sns import numpy as np # for sample data import pandas as pd # sample data np.random.seed(365) rows = 60 data1 = {'Type 1': ['a'] * rows, 'Total': np.random.normal(loc=25, ...
Cullen Wise's user avatar
4 votes
1 answer
2k views

ggplot of 2 ts-objects (time series) with 2 y axes (secondary y-axis)

I want to plot 2 ts-objects as bars and lines, respectively, using 2 y-axes. How can I do this in ggplot? I have 2 ts-objects: one is the value of a variable, the other is the annual change. The data ...
Isabel's user avatar
  • 95
4 votes
1 answer
3k views

automatically adjust axis limits while plotting separate plots together

I would like to automatically adjust the ggplot graphs while plotting side-by-side. library(ggplot2) library(gridExtra) set.seed(123) freq <- sample(1:10, 7, replace = T) labels <- c('AUS', '...
Prradep's user avatar
  • 5,666
4 votes
2 answers
3k views

Latex in y-axis title in plotly not working

Can you please tell me why fig.update_yaxes(title=dict(text="$\text{This is a test:} \sqrt{2^4}$") does not work in the following code import plotly.express as px fig = px.bar(df, x=["...
hans's user avatar
  • 333
3 votes
2 answers
10k views

Force y axis to start at 0, insert "break", AND have a large y axis using ggplot2 [duplicate]

I am still working on finalizing a reproducible figure for publication. Reviewers would like to see the below plot's y-axis start at 0 and include line break "//". The y-axis will need to ...
Millionhorns's user avatar
3 votes
1 answer
9k views

How to rotate Seaborn heatmap in python?

default settings of seaborn.heatmap gives the x-axis starts from the origin of 0 then increases towards the right the y-axis starts from an origin of 9 then increases towards the upward This is odd ...
develarist's user avatar
  • 1,345
3 votes
2 answers
1k views

R barplot - how to add y axis '%' suffix?

pdf("whatever.pdf", height=4,width=8) B <- c(0,0.585,0.043,0.006,0.012,0.244,0.004,0.008,0.119,0.012,0.095) barplot(B, names.arg = c("ce","de","en","es","fr","it","ja","nl","ru","sv","All"), las=1, ...
mwra's user avatar
  • 317

1
2 3 4 5
12