  C RUBY-ON-RAILS MYSQL ASP.NET DEVELOPMENT RUBY .NET LINUX SQL-SERVER REGEX WINDOWS ALGORITHM ECLIPSE VISUAL-STUDIO STRING SVN PERFORMANCE APACHE-FLEX UNIT-TESTING SECURITY LINQ UNIX MATH EMAIL OOP LANGUAGE-AGNOSTIC VB6 MSBUILD # How can I scale my y axis into y**constant  » python » How can I scale my y axis into y**constant

By : Ury Marshak
Date : November 14 2020, 04:48 PM
will be helpful for those in need You will have to define your own axis scale for this. My answer is based on this answer and the custom scale example.
This is the custom scaling class: code :
``````import matplotlib.pyplot as plt
import numpy as np
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.CustomTransform(self.thresh)

def set_default_locators_and_formatters(self, axis):
pass

class CustomTransform(mtransforms.Transform):
input_dims = 1
output_dims = 1
is_separable = True

def __init__(self, thresh):
mtransforms.Transform.__init__(self)
self.thresh = thresh

def transform_non_affine(self, a):
return a**(R/cp)

def inverted(self):
return CustomScale.InvertedCustomTransform(self.thresh)

class InvertedCustomTransform(mtransforms.Transform):
input_dims = 1
output_dims = 1
is_separable = True

def __init__(self, thresh):
mtransforms.Transform.__init__(self)
self.thresh = thresh

def transform_non_affine(self, a):
return a**(cp/R)

def inverted(self):
return CustomScale.CustomTransform(self.thresh)

# Now that the Scale class has been defined, it must be registered so
# that ``matplotlib`` can find it.
mscale.register_scale(CustomScale)
``````
``````plt.gca().set_yscale('custom')
`````` ## Individual axis limits with scale(expand) and scale=free in facetted ggplots

By : moe230
Date : March 29 2020, 07:55 AM
Hope that helps You may want to use a geom_blank():
Please be considerate and try not to confound the user! This type of transformation can be dangerous!
code :
``````library(ggplot2)

df <- data.frame(Treatment=c("A", "B","A","B"), Value=c(3,4, 20,2), SE=c(1,1,5,1), Type=c("c1","c1","c2","c2"))

ggplot(df, aes(Treatment, Value,fill=Treatment)) +
geom_bar(stat="identity", col="Black") +
geom_errorbar(aes(ymax = Value + SE, ymin=Value), col="black") +
geom_blank(aes(y=Value + SE + 1)) +
facet_wrap(~Type, scale="free_y") +
theme(panel.background = element_blank(),
panel.border = element_rect(colour = "black", fill=NA),
strip.background = element_blank()) +
scale_y_continuous(expand = c(0,0))
``````
``````ggplot(df, aes(Treatment, Value,fill=Treatment)) +
geom_bar(stat="identity", col="Black") +
geom_errorbar(aes(ymax = Value + SE, ymin=Value), col="black") +
geom_blank(aes(y=Value + 2 * SE)) +
facet_wrap(~Type, scale="free_y") +
theme(panel.background = element_blank(),
panel.border = element_rect(colour = "black", fill=NA),
strip.background = element_blank()) +
scale_y_continuous(expand = c(0,0))
`````` ## How to scale the errorbars to the dimensions of the right y-axis in a plot with one x-axis and two y-axis

By : user2978429
Date : March 29 2020, 07:55 AM
it helps some times I have a dataframe df1 as below. , You forgot your parentheses. Instead of
code :
`````` ymin = df1\$mean*494.2611 - df1\$ci
``````
`````` ymin = (df1\$mean - df1\$ci) * 494.2611
`````` ## Adjust the grid x-axis scale and y-axis scale in PairGrid method of seaborn

By : Wangi
Date : March 29 2020, 07:55 AM
I hope this helps you . I am struggling with getting the right x-axis and y-axis scale for my PairGrid plot of seaborn. , The bottom plot is produced via the classic style.
code :
``````from matplotlib import pyplot as plt
plt.style.use("classic")
import seaborn as sns
sns.set()

x = sns.PairGrid(iris, hue='species')
x = x.map_diag(plt.hist)
x = x.map_offdiag(plt.scatter)

plt.show()
`````` ## How can I keep a constant text-size and x-axis scale across multiple ungrouped plots

By : Damien Boué
Date : March 29 2020, 07:55 AM
will help you One (unfortunately not so lazy) approach would be to extract the legends as separate grobs (graphical objects), then lay out the plots and legends separately. This gives you more control over how much space is allocated to each object. Fortunately, a couple of helper functions make the process relatively painless. Here's an example: ## Matplotlib Histogram scale y-axis by a constant factor

By : LauInfor
Date : March 29 2020, 07:55 AM
hop of those help? The easiest way to do it is to define your axis and then multiply the ticks of your axis. For example 