Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

add sign to y axis values python

# For Python 3
# In place of the dollar sign $ put any sign you would need

graph.yaxis.set_major_formatter('${x:1.2f}')
Comment

add sign to y axis values python


import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.ticker as mtick

df = pd.DataFrame({'A': ['A', 'B'], 'B': [1000,2000]})

fig, ax = plt.subplots(1, 1, figsize=(2, 2))
df.plot(kind='bar', x='A', y='B',
        align='center', width=.5, edgecolor='none', 
        color='grey', ax=ax)

fmt = '${x:,.0f}'
tick = mtick.StrMethodFormatter(fmt)
ax.yaxis.set_major_formatter(tick) 
plt.xticks(rotation=25)

plt.show()

Comment

PREVIOUS NEXT
Code Example
Python :: pandas condense dataframe by summing according to ID 
Python :: dd-mm-yy to yyyy-mm-dd in python 
Python :: Faster way to find list of unique elements in a list 
Python :: c++ to python online converter 
Python :: add many instances to related field manytoamny django] 
Python :: qq plot using seaborn 
Python :: fibonacci sequence python 2.7 
Python :: fibonacci series recursive python 
Python :: repeats in python 
Python :: make my own rabbit bomb using python 
Python :: python sum over specific indexes 
Python :: Get Dates Between Two Ranges 
Python :: copy element dynamo revit 
Python :: access kwargs in template django 
Python :: Symbol to make things not equeal to something in python 
Python :: rename duplicates in list python 
Python :: step out pdb python 
Python :: Saving a copy of rcParams settings. 
Python :: "opencv write video" 
Python :: how to convert nonetype to list in python 
Python :: Jupyter to access jupyter notebook on virtualbox guest through browser in windows host 
Python :: quadkey calculator 
Python :: Default rows values display 
Python :: restrict memory use python code 
Python :: Code example of Python Modulo Operator with Exception handling 
Python :: negative list slicing 
Python :: python print numbers with commas 
Python :: travers a list 
Python :: find all html files in a current directory using regular expression in python 
Python :: Python NumPy broadcast_arrays() Function Syntax 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =