Skip to main content

Create Persian plots using matplotlob/seaborn

Project description

plotfa

plotfa defines a set of helper functions that will aid you in creating crisp and beautiful plots in Persian, using seaborn (preferably) or pure matplotlib.

Installation

plotfa can be installed using pip:

pip install plotfa

Basic Usage

After installing plotfa, we simply import it at the top of our file:

import plotfa

It's important to note that any bit of persian text that we want shown on the plot, must pass through the plotfa.fa() function. For simplicity, we explicitly import this function on the top:

from plotfa import fa

Now, let's say we want to create a little bar plot using seaborn, so:

import seaborn as sns
from plotfa import farsi as fa
import plotfa

sns.set_style('darkgrid')
# Set plot's settings
plotfa.set_font('B Yekan')  # It defaults to B Yekan already
plotfa.prettify()  # To make our plots look better

# We must wrap persian strings with the fa() function

y = [       
     fa('میله‌ی اول'),
     fa('میله‌ی دوم'),
     fa('میله‌ی سوم')
    ]
x = [
     10,
     20,
     15
    ]

sample_plot = sns.barplot(x, y) # save the returned plot object
# pass the plot object into modify_plot and set its title and labels
plotfa.modify_plot(plot=sample_plot,
                   title=fa('پلاتفا'),
                   xlabel=fa('تعداد'),
                   ylabel=fa('اسم میله'))

Running the above code, will result in the following plot: result of our basic usage

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

plotfa-0.0.5.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

plotfa-0.0.5-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file plotfa-0.0.5.tar.gz.

File metadata

  • Download URL: plotfa-0.0.5.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6

File hashes

Hashes for plotfa-0.0.5.tar.gz
Algorithm Hash digest
SHA256 d4e2a77fc740a03df229d3761f616131507dce20ec38b781186a88c13d083de0
MD5 035fc3c70485fe7a700cea9fea0dcc42
BLAKE2b-256 e13e820f1d1287ed5840664c776971afeff06288bf61682f0cc5de21f8bbf77b

See more details on using hashes here.

File details

Details for the file plotfa-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: plotfa-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 16.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6

File hashes

Hashes for plotfa-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 1daf3fc64d8a55746c727785e23836236b23f3fab911c63c5a0112c14c93a4e7
MD5 fbaa2ce95437762f0ba804acca90ae62
BLAKE2b-256 2d4fc605b95e32631844d2c8b8d2aa4ff91a026d5ca31fca7e46d56f1a6e6108

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page