They are exactly the same, and are used in a similar way to "however" or "on the other hand" to introduce a contrast / comparison. Put "By / In contrast" at the beginning of a sentence, with a comma after "contrast".
Example
Unemployment rose in the UK. By contrast, the number of unemployed people in Canada fell.
On the contrary
I don't think you'll need this phrase for any part of the IELTS test. It doesn't mean the same thing as "by / in contrast". We use "on the contrary" to deny that something is true, and to explain that the opposite is true.
Example
- Person 1: "You had some problems with your hotel, didn't you?"
- Person 2: "On the contrary, the hotel was great, but the airline lost my suitcase.”
TOEFL Grammar: 'by/in contrast' and 'on the contrary'
不建议同学们写托福作文的时候使用'by/in contrast' and 'on the contrary’这两个词组
理由:词海中显示But/However是强词,单词有强弱之分,这就是为什么On the countrary 在托福语法中归为递进关系而非转折
(请大家翻译下汉语:我家门前有条小河但是只能在5楼看到,地道的表达下期解析)
reference: