logo
down
shadow

How can I scale my y axis into y**constant


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')


Share : facebook icon twitter icon
Individual axis limits with scale(expand) and scale=free in facetted ggplots

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

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

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()

iris = sns.load_dataset("iris")


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

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

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

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
Related Posts Related Posts :
  • Use `tf.image.resize_image_with_crop_or_pad` to resize numpy array
  • Sum number of occurences of string per row
  • Calculating 'Diagonal Distance' in 3 dimensions for A* path-finding heuristic
  • porting PyGST app to GStreamer1.0 + PyGI
  • Connection refused in Tornado test
  • How much time does take train SVM classifier?
  • Turning a string into list of positive and negative numbers
  • Python lists get specific length of elements from index
  • python.exe version 3.3.2 64 & 32 crash while creating .exe file on win 7 64 & 32 with cx_Freeze
  • Efficient nearest neighbour search for sparse matrices
  • django filter_horizontal can't display
  • How to install FLANN and pyflann on Windows
  • How can I plot the same figure standalone and in a subplot in Matplotlib?
  • read-only cells in ipython notebook
  • filling text file with dates
  • error:AttributeError: 'super' object has no attribute 'db_type' when run "python manage.py syncdb" in django
  • python imblearn make_pipeline TypeError: Last step of Pipeline should implement fit
  • Write to csv: columns are shifted when item in row is empty (Python)
  • DuckDuckGo search returns 'List Index out of range'
  • Python function which can transverse a nested list and print out each element
  • Python installing xlwt module error
  • Python mayavi: Adding points to a 3d scatter plot
  • Making a basic web scraper in Python with only built in libraries - Python
  • How to calculate the angle of the sun above the horizon using pyEphem
  • Fix newlines when writing UTF-8 to Text file in python
  • How to convert backward slash command in python to run on Linux
  • PyCharm Code Inspection doesn't include PEP 8
  • How can I use Python namedtuples to insert rows into mySQL database
  • Increase / Decrease Mac Address in Python from String
  • Scrollable QLabel image in PyQt5
  • (Python 2.7) Access variable from class with accessor/mutator
  • Why does "from [Module] import [Something]" takes more time than "import [Module"
  • jira python oauth: how to get the parameters for authentication?
  • Python - How to specify a relative path by jumping a subdirectory?
  • Extract scientific number from string
  • Scrapy: Python cannot find the spider
  • get the values in a given radius from numpy array
  • Is it possible to duplicate a pipe in Python, so that it has one write end but two read ends?
  • Why does wget use Firefox cookies to login on an authenticated webpage?
  • python import behaviour: different objects from same file?
  • Create YoY Graph with Matplotlib
  • Safe use of eval() or alternatives - python
  • Unix change desktop background seamlessly
  • Profiling Python code that uses multiprocessing?
  • How to query a database after render_template
  • shifting right in for loop over indices in python
  • Is there a way to switch code indentation from tabs to spaces across the project, and to keep 'hg annotate' functionalit
  • Disable/Close/Quit/Exit Terminal screen from python on Geany (Ubuntu)
  • for i in xrange() not running the complete script
  • ImportError ropevim using ropevim plugin in vim
  • How to read each line from a file into list word by word in Python
  • Creating Unique Names
  • python split a string when a keyword comes after a pattern
  • Same Python code returns different results for same input string
  • Call a Flask function every few minutes
  • Python: Using Ghost for dynamic webscraping
  • How to make while iteration faster?
  • Struggling to resolve "a float is required error" in python
  • Read data with NAs into python and calculate mean row-wise
  • How to print telnet response line by line?
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org