Saturday, December 30, 2017

How to Multiplots on Same Canvas using Matplotlib

Subplot function can be used to plot multiple graphs in same canvas.

Case 1:- Create graph in same ROW


import matplotlib.pyplot as plt
import numpy as np
 
%matplotlib inline
    
x = np.linspace(0, 5, 11)
y = x ** 2
 
#Instantiate figure and axes object. 
#fig, ax = plt.subplots()
 
# bydefualt on not passing any parameters in constructor, Just a figure and one subplot
f, ax = plt.subplots(nrows=1, ncols=2)
ax[0].plot(x, y)
ax[0].set_title('Simple plot')

ax[1].plot(y, x)
ax[1].set_title('Simple plot')


Case 2:- Create graph in same Column



import matplotlib.pyplot as plt
import numpy as np
 
%matplotlib inline
    
x = np.linspace(0, 5, 11)
y = x ** 2
 
#Instantiate figure and axes object. 
#fig, ax = plt.subplots()
 
# bydefualt on not passing any parameters in constructor, Just a figure and one subplot
f, ax = plt.subplots(nrows=2, ncols=1)
ax[0].plot(x, y)
ax[0].set_title('Simple1 plot')

ax[1].plot(y, x)
ax[1].set_title('Simple2 plot')


Matplotlib/subplot/python Syntax and Analysis “fig, ax = plt.subplots()”


The Matplotlib subplot() function can be called to plot two or more plots in one figure. Matplotlib supports all kind of subplots including 2×1 vertical, 2×1 horizontal or a 2×2 grid.


# Import required library
import matplotlib.pyplot as plt
import numpy as np

#First create some toy data:
x = np.linspace(0, 5, 11)
y = x ** 2

#Instantiate figure and axes object. 
# bydefualt on not passing any parameters in constructor, Just a figure and one subplot
fig, ax = plt.subplots()
#Set Data
ax.plot(x, y)
#Set Title for the graph
ax.set_title('Simple plot')


Analysis of used code

#Instantiate figure and axes object. 
fig, ax = plt.subplots()

Important feature of the below code is we are using 2 variables for assignment on instantiation of object.

Reasoning

plt.subplots() is a function that returns a tuple containing a figure and axes object(s). Thus when using fig, ax = plt.subplots() you unpack this tuple into the variables fig and ax.Thus this can also be read as 2 below statement combined as one.

fig = plt.figure()
ax = fig.add_subplot(111)



f : matplotlib.figure.Figure object

ax : Axes object or array of Axes objects.

ax can be either a single  matplotlib.axes.Axes object or an array of Axes objects if more than one subplot was created. The dimensions of the resulting array can be controlled with the squeeze keyword, see above.

Thursday, December 28, 2017

List of Keywords in Python

Keywords are the reserved words in Python. We cannot use a keyword as variable name, function name or any other identifier.

Here's a list of all keywords in Python Programming

Keywords in Python programming language

Python : Built-in Functions

Method Description
Python abs() returns absolute value of a number
Python all() returns true when all elements in iterable is true
Python any() Checks if any Element of an Iterable is True
Python ascii() Returns String Containing Printable Representation
Python bin() converts integer to binary string
Python bool() Coverts a Value to Boolean
Python bytearray() returns array of given byte size
Python bytes() returns immutable bytes object
Python callable() Checks if the Object is Callable
Python chr() Returns a Character (a string) from an Integer
Python classmethod() returns class method for given function
Python compile() Returns a Python code object
Python complex() Creates a Complex Number
Python delattr() Deletes Attribute From the Object
Python dict() Creates a Dictionary
Python dir() Tries to Return Attributes of Object
Python divmod() Returns a Tuple of Quotient and Remainder
Python enumerate() Returns an Enumerate Object
Python eval() Runs Python Code Within Program
Python exec() Executes Dynamically Created Program
Python filter() constructs iterator from elements which are true
Python float() returns floating point number from number, string
Python format() returns formatted representation of a value
Python frozenset() returns immutable frozenset object
Python getattr() returns value of named attribute of an object
Python globals() returns dictionary of current global symbol table
Python hasattr() returns whether object has named attribute
Python hash() returns hash value of an object
Python help() Invokes the built-in Help System
Python hex() Converts to Integer to Hexadecimal
Python id() Returns Identify of an Object
Python input() reads and returns a line of string
Python int() returns integer from a number or string
Python isinstance() Checks if a Object is an Instance of Class
Python issubclass() Checks if a Object is Subclass of a Class
Python iter() returns iterator for an object
Python len() Returns Length of an Object
Python list() Function creates list in Python
Python locals() returns dictionary of current local symbol table
Python map() Applies Function and Returns a List
Python max() returns largest element
Python memoryview() returns memory view of an argument
Python min() returns smallest element
Python next() Retrieves Next Element from Iterator
Python object() Creates a Featureless Object
Python oct() converts integer to octal
Python open() Returns a File object
Python ord() returns Unicode code point for Unicode character
Python pow() returns x to the power of y
Python print() Prints the Given Object
Python property() returns a property attribute
Python range() return sequence of integers between start and stop
Python repr() returns printable representation of an object
Python reversed() returns reversed iterator of a sequence
Python round() rounds a floating point number to ndigits places.
Python set() returns a Python set
Python setattr() sets value of an attribute of object
Python slice() creates a slice object specified by range()
Python sorted() returns sorted list from a given iterable
Python staticmethod() creates static method from a function
Python str() returns informal representation of an object
Python sum() Add items of an Iterable
Python super() Allow you to Refer Parent Class by super
Python tuple() Function Creates a Tuple
Python type() Returns Type of an Object
Python vars() Returns __dict__ attribute of a class
Python zip() Returns an Iterator of Tuples
Python __import__() Advanced Function Called by import

Friday, May 16, 2014

Released Magento 1.9 Wait for Magento 1.9.1


2 Days back Magento released  has Community Edition 1.9. This is a major release after 1.8.1. Same as every other major release, Magento 1.9 has also under gone major changes. Following are highlights of this release are

Magento 1.9 Screenshot with demo data
  • Less Time and Less Cost to Get a Responsive Site
  • Cross Border Price Consistency
  • Improved Payment and Financing Options
  • Fresher Search Results for Customers and Faster Indexing for Merchants
  • Cross Border Price Consistency
  • Improved Quality and More Features
http://www.magentocommerce.com/knowledge-base/entry/ce19-later-release-notes


Wait for Magento 1.9.1

Historically Magento 1.x.0 version has always been vulnerable. And to plug-in the issues, magneto has always released 1.x.1 release in next 60 days. Historically 1.x.1 version has been one there most stable releases. Going by track record, I suggest users to avoid using magento 1.9 for production as upgrade or as a fresh installation. And its more interesting to observe that magento has release Magento CE 1.9.0.1 Version within 2 days of release of 1.9 version. 
After major release wait for bugs to be fixed. 


Saturday, April 12, 2014

Review : washingmachineclinic.com Bangalore

This is  2 months pending work. This Review is about Washing Machine Clinic, Bangalore (washingmachineclinic.com). 


I had a pathetic experience from washingmachineclinic.com. Previous to actual experience I was told about their prompt and efficient service. So I decided to call them.

Got attended after number of follow up


I called them in one evening for the appointment. And I got appointment for next day. But unfortunately nobody turned up. But after a number of follow up it got attended next day.

Very High and Random charges


The person came  to my place and examined the washing machine. Immediately after examination, the person told me motor is damaged and needs to be changed. He quoted Rs 4,200.  I was confused, that the company is supposed to service all kind of washing machine and they deal with several part. How come the person knows exact price of the part? How come he told me price without consulting any paper or person. 

Going by logic that the price of machine is Rs 10,000. So how can only part be of Rs 4,200 I opted NOT to go for the service.

Next day I called Godrej service center. And I got my machine repaired in only Rs 2,400. Rs 1,800 less from what Washing Machine clinic quoted.


Always eager to change parts

In another experience of my friends, they called for the appointment.  They explained the problem. Surprisingly, at the same moment,  on same call,  they suggested one of part to get replaced. My friend was very surprised to hear that. The person is suggesting diagnosis without even examining. Later on he got it repaired WITHOUT any replacement of the said part from some other mechanic.

NOT RECOMMENDED 

After my and my friend experience I would highly recommend NOT to go for the service. Instead, I would recommend to opt for either Company customer service or any near by mechanic. 

Thursday, April 3, 2014

Amethi : After 10 years, MP don't have House, Bank Account?

Hilarious, 2 time MP don't have a house in his constituency. After 10 years he don't have even a Bank account. Having house is a basic expectation from any MP. 

Moreover, for getting the residence proofs, occasional staying in the constituency is required.  And Surprisingly, his application was rejected with one the reason as, Rahul Gandhi don't even stay occasionally?


Amethi is my home : Rahul

I have many election speeches from Rahul Gandhi. One common sentence that I can hear in every speech since 2004 is "I am in-between my family. I in my home." The words has been consistent for last 10 years. But after this revelation, I am confused what does he really mean when saying those words. 

Is this emotional Drama?

I agree that we Indian's have been traditionally emotional. Historically we have taken more decisions based on emotions then on logic. It becomes very easy for any one to touch our emotional string. And historically people from Amethi too had a emotional connection with gandhi-nehru family. And Rahul Gandhi is using same for his elections. 

After 60 years, do you need more time to develop?


Amethi has been with Gandhi-Nehu Family for neary 60 years since Independence. In other words one family was having rule for 60 years. Even if one would have planned a long term(20 years)  plan for Amethi, he would have made it a Developed city. But sad part is Rahul Gandhi is still asking vote for issue on Poverty, Health and other basic amenities.  It is interesting to conclude  from the above instance that even after 60 years Amethi is fighting for basic amenities. Things could have been different if he would have stayed more.

And same conclusion applies for India as well. 


Windows 8.1 Update brings back Start Menu


Its official now, after a lots of roar by windows users for "Start Menu" , 8.1 brings back Start Menu. When Microsoft removed the Start menu, quite a few of its users were upset, and this move did indeed make Windows 8.1 harder to use for many. With re-addition Start menu  also got updates. Now Start Menu carries traditional UI combined with live tiles and other Metro-influenced UI elements.



There are some other notable features in Windows 8.1 Update. Here is a list:

  • For traditional users, like Windows 7, 8.1 is bootable in desktop mode unlike tiles view in previous version.
  • For traditional users, Right click on a tile of an application in Modern UI mode will open a context menu.
  • For traditional users, 8.1 re-powers Task bars.
  • Allows minimize re-accessible Windows apps like facebook, chat apps from Task bars  
  • Search and shutdown buttons are now always visible in the top right corner of the screen.


Video release by Windows on April 2, 2014



Monday, March 31, 2014

PM is not silent, spoke 1117 times in 10 years

On 28th March, in a Hilarious facts presented by Media manager of Prime minister of  India, he spoke 1117 times in 10 years of in 3,650 days.According to him PM spoke every third day.  He also went on counted the occasions on which he has spoken.



According to him, PM spoke on dinners,in functions,  in Rajyasabha, in Loksabha, in front on  media, in election rallies and many many other times. Panjak Pachori also gave the reason why PM dont believed in speaking too much. He explained PM belief as "Empty vessel makes noise".

When the UPA II government faced heat during the coalscam, the Prime Minister was quoted as saying in the Rajya Sabha, "Hazaron jawabo se achchi hai khamoshi meri, na jaane kitne sawalo ki aabru rakhe. (My silence is better than a thousand answers, it keeps intact the honour of innumerable questions). "



So going by the statement, if PM speaks in a dinner, then next time he will speak will be only third day, even if he is required to make statement in Parliament. Because he speaks only once in three days. This is does not ends here, even he tweeted. Kam Bola Kaam Bola.
The PM's Media manager's statement was not that hilarious but tweet from PM was certainly more hilarious.

I hope India will get a speaking Prime-minister this time.